Skip to content

Commit

Permalink
new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mdabdullah3 committed Jan 6, 2024
1 parent d324f5c commit a9b303b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/Http/Controllers/SubCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\SubCategory;
use App\Http\Requests\StoreSubCategoryRequest;
use App\Http\Requests\UpdateSubCategoryRequest;
use Illuminate\Http\Client\Request;
use Illuminate\Http\JsonResponse;

class SubCategoryController extends Controller
Expand Down Expand Up @@ -58,18 +59,17 @@ public function show($id): JsonResponse
/**
* Update the specified resource in storage.
*/
public function update(UpdateSubCategoryRequest $request, SubCategory $subCategory): JsonResponse
public function update(Request $request, SubCategory $subCategory)
{
$subCategory->update($request->all());

return response()->json([
'status' => 'success',
'message' => 'SubCategory updated successfully',
'data' => $subCategory,
$validated = $request->validate([
'name' => 'required|max:255',
'category_id' => 'required',
]);
return $subCategory->update($request->all());
}



public function destroy(SubCategory $subcategory)
{
$subcategory->delete();
Expand Down
2 changes: 2 additions & 0 deletions app/Models/subCategory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

// app/Models/SubCategory.php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand Down

0 comments on commit a9b303b

Please sign in to comment.