diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php index c56ed9f871..8b471f27b3 100644 --- a/app/Http/Controllers/Api/CompaniesController.php +++ b/app/Http/Controllers/Api/CompaniesController.php @@ -8,6 +8,7 @@ use App\Http\Transformers\CompaniesTransformer; use App\Http\Transformers\SelectlistTransformer; use App\Models\Company; use Illuminate\Http\Request; +use App\Http\Requests\ImageUploadRequest; use Illuminate\Support\Facades\Storage; class CompaniesController extends Controller @@ -65,15 +66,16 @@ class CompaniesController 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', Company::class); $company = new Company; $company->fill($request->all()); - + $company = $request->handleImages($company); + if ($company->save()) { return response()->json(Helper::formatStandardApiResponse('success', (new CompaniesTransformer)->transformCompany($company), trans('admin/companies/message.create.success'))); } @@ -104,15 +106,16 @@ class CompaniesController 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', Company::class); $company = Company::findOrFail($id); $company->fill($request->all()); + $company = $request->handleImages($company); if ($company->save()) { return response()