/** * Deletes a photo in the portfolio album */ public function deleteAlbumPhoto($id) { $photo = PortfolioAlbumPhoto::find($id); unlink(public_path($photo->photo_path)); $photo->delete(); return redirect()->back(); }
public function portfolioPhotos(Request $request) { $images = $request->files->get('image'); $portfolio_album_id = $request->input("portfolio_album_id"); foreach ($images as $image) { $filename = time() . "-" . $image->getClientOriginalName(); $path = public_path('assets/images/portfolio_albums/' . $portfolio_album_id . '/' . $filename); //open image file $photo = Image::make($image->getRealPath()); $photo->save($path, 100); //save high resolution photo $portfolioPhoto = new PortfolioAlbumPhoto(); $portfolioPhoto->photo_path = 'assets/images/portfolio_albums/' . $portfolio_album_id . '/' . $filename; $portfolioPhoto->portfolio_album_id = $portfolio_album_id; $portfolioPhoto->save(); } }