/**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(Banner $banner, BannerRequest $request)
 {
     $oldImage = null;
     if ($request->file('upl')) {
         $oldImage = Attachment::where('id', $banner->attachment_id);
         $imageModel = ImageUploadFacade::attachmentUpload($request->file('upl'), new Attachment(), 'banners');
         $banner->attachment_id = $imageModel->id;
     }
     $banner->paid = $request->paid == 'on' ? 1 : 0;
     $banner->update($request->input());
     if ($oldImage) {
         $oldImage->delete();
     }
     return redirect()->route('admin.banner.index');
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(BannerRequest $request, $id)
 {
     $banner = Banner::findOrFail($id);
     $banner->update($request->all());
     $banner->updateCat(['cat' => [$request->input('cat')], 'id' => $id]);
     flash()->success(trans('banners.updated'));
     return redirect(action('Admin\\BannersController@index'));
 }