diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index a3c2bcd2ca..1f6d47eeb3 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -21,6 +21,7 @@ use Carbon\Carbon; use DB; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; +use App\Http\Requests\ImageUploadRequest; use Input; use Paginator; use Slack; @@ -404,11 +405,11 @@ class AssetsController extends Controller * Accepts a POST request to create a new asset * * @author [A. Gianotto] [] - * @param Request $request + * @param \App\Http\Requests\ImageUploadRequest $request * @since [v4.0] * @return JsonResponse */ - public function store(Request $request) + public function store(ImageUploadRequest $request) { $this->authorize('create', Asset::class); @@ -452,6 +453,8 @@ class AssetsController extends Controller $asset->image = $saved_image_path; } + $asset = $request->handleImages($asset); + // Update custom fields in the database. // Validation for these fields is handled through the AssetRequest form request $model = AssetModel::find($request->get('model_id')); @@ -513,11 +516,11 @@ class AssetsController extends Controller * Accepts a POST request to update an asset * * @author [A. Gianotto] [] - * @param Request $request + * @param \App\Http\Requests\ImageUploadRequest $request * @since [v4.0] * @return JsonResponse */ - public function update(Request $request, $id) + public function update(ImageUploadRequest $request, $id) { $this->authorize('update', Asset::class); @@ -556,6 +559,8 @@ class AssetsController extends Controller } } + $asset = $request->handleImages($asset); + // Update custom fields if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) { foreach ($model->fieldset->fields as $field) {