예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateAlbumRequest $request
  * @return Response
  */
 public function store(CreateAlbumRequest $request, Album $album)
 {
     $uploaded_file = $request->file('image_file');
     $parameter = $request->all();
     unset($parameter['image_file']);
     $album = $album->create($parameter);
     if (isset($uploaded_file)) {
         $ext = $uploaded_file->getClientOriginalExtension();
         $imageName = $album->id . "." . $ext;
         $uploaded_file->move(base_path() . '/public/img/uploads/album/', $imageName);
         Image::make(base_path() . '/public/img/uploads/album/' . $imageName, array('width' => 160, 'height' => 200))->save(base_path() . '/public/img/uploads/thumbnails/album/' . $imageName);
         $album->update(array('image' => $imageName));
     }
     Session::flash('message', 'The Album was successfully added!.');
     Session::flash('flash_type', 'alert-success');
     return redirect('albums');
 }
예제 #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(CreateAlbumRequest $request, $slug)
 {
     //dd($id);
     $imageName = $request->albumName . '.' . $request->file('imageFile')->getClientOriginalExtension();
     $albumUpdate = $this->album->whereSlug($slug)->first();
     //dd($albumUpdate);
     $albumUpdate->fill(['albumName' => $request->get('albumName'), 'slug' => $request->get('slug'), 'albumImageName' => $imageName, 'artist_id' => $request->get('artist'), 'year' => $request->get('year')]);
     $albumUpdate->save();
     $request->file('imageFile')->move(base_path() . '/public/images/album/', $imageName);
     return redirect('album')->with('message', 'Album Updated!');
 }