From aa402bf8966f677346adde1480dfcf4c56f45b6c Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 29 Jun 2021 12:26:15 +0300 Subject: [PATCH] Support images and multipart requests --- app/Http/Controllers/Api/AssetModelsController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index abc1f65a5a..9bc3e46cfe 100644 --- a/app/Http/Controllers/Api/AssetModelsController.php +++ b/app/Http/Controllers/Api/AssetModelsController.php @@ -9,6 +9,7 @@ use App\Http\Transformers\SelectlistTransformer; use App\Models\Asset; use App\Models\AssetModel; use Illuminate\Http\Request; +use App\Http\Requests\ImageUploadRequest; use Illuminate\Support\Facades\Storage; /** @@ -107,14 +108,15 @@ class AssetModelsController 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', AssetModel::class); $assetmodel = new AssetModel; $assetmodel->fill($request->all()); + $assetmodel = $request->handleImages($assetmodel); if ($assetmodel->save()) { return response()->json(Helper::formatStandardApiResponse('success', $assetmodel, trans('admin/models/message.create.success'))); @@ -159,16 +161,17 @@ class AssetModelsController 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', AssetModel::class); $assetmodel = AssetModel::findOrFail($id); $assetmodel->fill($request->all()); - + $assetmodel = $request->handleImages($assetmodel); + /** * Allow custom_fieldset_id to override and populate fieldset_id. * This is stupid, but required for legacy API support.