/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $album = ClientAlbum::find($id); $itemsPerPage = 12; $total = ClientAlbumPhoto::where('client_album_id', '=', $id)->count(); $last = ceil($total / $itemsPerPage); return View('clients.purchase_album')->with('title', $album->album_name)->with('last', $last)->with('itemsPerPage', 12)->with('albumID', $id)->with('maxPhotos', $album->photo_selection_max)->with('orderID', ''); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $formats = PhotoFormat::all(); $album = ClientAlbum::find($id); $itemsPerPage = 12; $total_rows = ClientAlbumPhoto::where('client_album_id', '=', $id)->count(); $last = ceil($total_rows / $itemsPerPage); return View('clients.purchase_prints')->with('title', $album->album_name)->with('albumID', $id)->with('last', $last)->with('itemsPerPage', 12)->with('photo_formats', $formats)->with('orderID', ''); }
/** * Show the form for editing a client's order. * * @param int $id * @return Response */ public function edit($id) { $order = Order::find($id); $album = $order->album; $itemsPerPage = 12; $total = ClientAlbumPhoto::where('client_album_id', '=', $album->id)->count(); $last = ceil($total / $itemsPerPage); if (strcmp($order->type, 'Prints Order') == 0) { return View('clients.purchase_prints')->with('title', $album->album_name)->with('albumID', $album->id)->with('last', $last)->with('itemsPerPage', 12)->with('orderID', $id); } else { return View('clients.purchase_album')->with('title', $album->album_name)->with('albumID', $album->id)->with('last', $last)->with('itemsPerPage', 12)->with('orderID', $order->id)->with('maxPhotos', $album->photo_selection_max); } }
public function albumPhotos(Request $request) { $images = $request->files->get('images'); $client_album_id = $request->input("client_album_id"); foreach ($images as $image) { $filename = time() . "-" . $image->getClientOriginalName(); $lowPath = public_path('assets/images/client_albums/' . $client_album_id . '/low_res/' . $filename); $highPath = public_path('assets/images/client_albums/' . $client_album_id . '/high_res/' . $filename); //open image file $photo = Image::make($image->getRealPath()); $photo->save($highPath, 100); //save high resolution photo $photo->resize(null, 600, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->save($lowPath, 80); //save low resolution photo $albumPhoto = new ClientAlbumPhoto(); $albumPhoto->photo_path_low_res = 'assets/images/client_albums/' . $client_album_id . '/low_res/' . $filename; $albumPhoto->photo_path_high_res = 'assets/images/client_albums/' . $client_album_id . '/high_res/' . $filename; $albumPhoto->client_album_id = $client_album_id; $albumPhoto->save(); } }
/** * Remove the specified client from storage. * * @param int $id * @return Response */ public function destroy($id) { $client = Client::find($id); if (count($client->orders)) { return redirect()->back()->with('message', FlashMessage::DisplayAlert('Cannot delete a client that has an order.', 'success')); } else { $albums = $client->albums; foreach ($albums as $album) { //delete folder and Photos from server $this->dispatch(new DeleteFolderFileCommand(public_path("assets/images/client_albums/" . $album->id))); unlink(public_path($album->album_cover_photo)); //delete from database ClientAlbumPhoto::where("client_album_id", "=", $album->id)->delete(); $album->delete(); } if ($client->profile_photo) { unlink(public_path($client->profile_photo)); } $user = $client->user; $client->delete(); $user->delete(); return redirect('/admin/dashboard/clients'); } }
public function deleteAlbumPhoto($id) { $photo = ClientAlbumPhoto::find($id); if (count($photo->printsOrderSelection) || count($photo->albumOrderSelection)) { return redirect()->back->with('message', 'Cannot delete a photo that is in an order.'); } else { unlink(public_path($photo->photo_path_low_res)); unlink(public_path($photo->photo_path_high_res)); $photo->delete(); return redirect()->back(); } }