/**
  * 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);
     }
 }
 /**
  * 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');
     }
 }
 /**
  * Deletes a client album if there are no orders made on album.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($client_id, $album_id)
 {
     $album = ClientAlbum::find($album_id);
     if (count($album->orders)) {
         return redirect()->back()->with('message', FlashMessage::DisplayAlert('Cannot delete album.  This album has been ordered by client', 'success'));
     } else {
         $coverPhoto = $album->album_cover_photo;
         $albumPhotos = $album->photos;
         //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();
         return redirect('/admin/dashboard/clients/' . $client_id . '/albums')->with('message', FlashMessage::DisplayAlert('Successfully deleted album!', 'success'));
     }
 }