From f9da83bc467e79a9ea8d6efd417eb29aeea4127b Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 29 Jun 2021 12:28:42 +0300 Subject: [PATCH] Support images and multipart requests --- app/Http/Controllers/Api/LocationsController.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index ed71685159..6d70e7aaf1 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Api; use Illuminate\Http\Request; +use App\Http\Requests\ImageUploadRequest; use App\Http\Controllers\Controller; use App\Helpers\Helper; use App\Models\Location; @@ -86,14 +87,15 @@ class LocationsController 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', Location::class); $location = new Location; $location->fill($request->all()); + $location = $request->handleImages($location); if ($location->save()) { return response()->json(Helper::formatStandardApiResponse('success', (new LocationsTransformer)->transformLocation($location), trans('admin/locations/message.create.success'))); @@ -141,17 +143,17 @@ class LocationsController 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\JsonResponse */ - public function update(Request $request, $id) + public function update(ImageUploadRequest $request, $id) { $this->authorize('update', Location::class); $location = Location::findOrFail($id); $location->fill($request->all()); - + $location = $request->handleImages($location); if ($location->isValid()) {