diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php index 8a60f343b9..8c8bb317e2 100644 --- a/app/Http/Controllers/Api/CategoriesController.php +++ b/app/Http/Controllers/Api/CategoriesController.php @@ -8,6 +8,7 @@ use App\Http\Transformers\CategoriesTransformer; use App\Http\Transformers\SelectlistTransformer; use App\Models\Category; use Illuminate\Http\Request; +use App\Http\Requests\ImageUploadRequest; use Illuminate\Support\Facades\Storage; class CategoriesController extends Controller @@ -53,14 +54,15 @@ class CategoriesController extends Controller * * @author [A. Gianotto] [] * @since [v4.0] - * @param \Illuminate\Http\Request $request + * @param \App\Http\Requests\ImageUploadRequest $request * @return \Illuminate\Http\Response */ - public function store(Request $request) + public function store(ImageUploadRequest $request) { $this->authorize('create', Category::class); $category = new Category; $category->fill($request->all()); + $category = $request->handleImages($category); if ($category->save()) { return response()->json(Helper::formatStandardApiResponse('success', $category, trans('admin/categories/message.create.success'))); @@ -90,15 +92,16 @@ class CategoriesController extends Controller * * @author [A. Gianotto] [] * @since [v4.0] - * @param \Illuminate\Http\Request $request + * @param \App\Http\Requests\ImageUploadRequest $request * @param int $id * @return \Illuminate\Http\Response */ - public function update(Request $request, $id) + public function update(ImageUploadRequest $request, $id) { $this->authorize('update', Category::class); $category = Category::findOrFail($id); $category->fill($request->all()); + $category = $request->handleImages($category); if ($category->save()) { return response()->json(Helper::formatStandardApiResponse('success', $category, trans('admin/categories/message.update.success')));