Skip to content

Commit

Permalink
size controller code done
Browse files Browse the repository at this point in the history
  • Loading branch information
Mdabdullah3 committed Jan 6, 2024
1 parent 17eb9ef commit 7852bb5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
2 changes: 0 additions & 2 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public function update(UpdateCategoryRequest $request, Category $category)
$category->update($request->validated());
return response()->json(['message' => 'Category updated successfully', 'category' => $category]);
}


/**
* Remove the specified resource from storage.
*/
Expand Down
37 changes: 29 additions & 8 deletions app/Http/Controllers/SizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,83 @@
use App\Models\size;
use App\Http\Requests\StoresizeRequest;
use App\Http\Requests\UpdatesizeRequest;
use Illuminate\Http\JsonResponse;

class SizeController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
public function index(): JsonResponse
{
//
$size = size::all();
return response()->json([
'status' => 'success',
'code' => 200,
'data' => $size
]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(StoresizeRequest $request)
{
//
$size = size::create($request->all());
return response()->json([
'status' => 'success',
'code' => 200,
'data' => $size,
]);
}

/**
* Display the specified resource.
*/
public function show(size $size)
{
//
$size = size::find($size);
return response()->json([
'status' => 'success',
'code' => 200,
'data' => $size,
]);
}

/**
* Show the form for editing the specified resource.
*/
public function edit(size $size)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(UpdatesizeRequest $request, size $size)
{
//
$size->update($request->validated());
return response()->json([
'message' => 'Size updated successfully'
]);
}

/**
* Remove the specified resource from storage.
*/
public function destroy(size $size)
{
//
$size->delete();
return response()->json([
'status' => 'Successfully',
'message' => 'Size deleted successfully'
]);
}
}
5 changes: 5 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use App\Http\Controllers\CategoryController;
use App\Http\Controllers\SizeController;
use App\Http\Controllers\SubCategoryController;
use App\Http\Controllers\UserController;
use Illuminate\Http\Request;
Expand All @@ -10,6 +11,10 @@
Route::apiResource('users', UserController::class);
Route::apiResource('categories', CategoryController::class);
Route::apiResource('subcategories', SubCategoryController::class);
Route::apiResource('sizes', SizeController::class);


// Not Found Route
Route::fallback(function (Request $request) {
return response()->json([
'message' => 'Not Found',
Expand Down

0 comments on commit 7852bb5

Please sign in to comment.