From f1b8ce0a1b15b4dec905e9ec028ddbea508d29ed Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 29 Jun 2021 12:28:52 +0300 Subject: [PATCH] Support images and multipart requests --- app/Http/Controllers/Api/ManufacturersController.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/ManufacturersController.php b/app/Http/Controllers/Api/ManufacturersController.php index 51dc2c496b..6fb8015597 100644 --- a/app/Http/Controllers/Api/ManufacturersController.php +++ b/app/Http/Controllers/Api/ManufacturersController.php @@ -8,6 +8,7 @@ use App\Http\Transformers\ManufacturersTransformer; use App\Http\Transformers\SelectlistTransformer; use App\Models\Manufacturer; use Illuminate\Http\Request; +use App\Http\Requests\ImageUploadRequest; use Illuminate\Support\Facades\Storage; class ManufacturersController extends Controller @@ -58,14 +59,15 @@ class ManufacturersController 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', Manufacturer::class); $manufacturer = new Manufacturer; $manufacturer->fill($request->all()); + $manufacturer = $request->handleImages($manufacturer); if ($manufacturer->save()) { return response()->json(Helper::formatStandardApiResponse('success', $manufacturer, trans('admin/manufacturers/message.create.success'))); @@ -95,15 +97,16 @@ class ManufacturersController 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', Manufacturer::class); $manufacturer = Manufacturer::findOrFail($id); $manufacturer->fill($request->all()); + $manufacturer = $request->handleImages($manufacturer) if ($manufacturer->save()) { return response()->json(Helper::formatStandardApiResponse('success', $manufacturer, trans('admin/manufacturers/message.update.success')));