Пример #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param BrandFormRequest $brandForm
  * @param Brand            $brand
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(BrandFormRequest $brandForm, Brand $brand)
 {
     $input = $brandForm->all();
     if ($brandForm->hasFile('logo') && $brandForm->file('logo')->isValid()) {
         $input['logo'] = file_get_contents($brandForm->file('logo')->getRealPath());
     }
     $brand->update($input);
     return Redirect::route('admin.brands.show', $brand->id)->with('message', 'Brand has been updated.');
 }
Пример #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param BrandFormRequest $brandForm
  * @param Brand $brand
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(BrandFormRequest $brandForm, Brand $brand)
 {
     // may we edit this brand
     if (!$brand->mayEdit($this->auth_user)) {
         return Redirect::route('admin.brands.show', $brand->id)->with('message', 'User is not authorized to edit this brand.');
     }
     $input = $brandForm->all();
     if ($brandForm->hasFile('logo') && $brandForm->file('logo')->isValid()) {
         $errors = [];
         if (!Brand::checkUploadedLogo($brandForm->file('logo'), $errors)) {
             return Redirect::route('admin.brands.edit', $brand->id)->withErrors(['logo' => $errors]);
         }
         // all ok
         $filesystem = new Filesystem();
         $input['logo'] = $filesystem->get($brandForm->file('logo')->getRealPath());
     }
     $brand->update($input);
     return Redirect::route('admin.brands.show', $brand->id)->with('message', 'Brands has been updated.');
 }