/** * 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', ''); }
/** * 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')); } }
/** * Handle an incoming request. * This middleware ensures that no logged on client can * view or order another clients albums. * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $uri = $_SERVER['REQUEST_URI']; $tokens = explode('/', $uri); if (count($tokens) == 5) { $album_id = $tokens[sizeof($tokens) - 1]; } else { $album_id = $tokens[sizeof($tokens) - 2]; } $album = ClientAlbum::find($album_id); if ($album != null) { $album_user = $album->client->user; } if ($album == null || $request->user()->id != $album_user->id) { return redirect('/user/dashboard'); } return $next($request); }
public function printsPurchase(Request $request) { $photos = $request->photos; $albumID = $request->album_id; $album = ClientAlbum::find($albumID); $client = $album->client; $clientName = $client->first_name . " " . $client->last_name; $orderID = $request->order_id; if ($orderID != '') { $order = Order::find($orderID); DB::table('client_prints_selections')->where('print_order_id', '=', $orderID)->delete(); Session::flash('message', FlashMessage::DisplayAlert('Your prints purchase was saved!', 'success')); } else { //create prints order in database $order = new Order(); $order->client_album_id = $albumID; $order->client_id = $client->id; $order->status = "In Progress"; $order->type = "Prints Order"; $order->save(); Session::flash('message', FlashMessage::DisplayAlert('Your prints purchase was successful!', 'success')); Mail::send('emails.order_confirmation', [], function ($message) use($client, $clientName) { $message->to($client->email, $clientName)->subject('Prints Order Received'); }); } foreach ($photos as $photo) { $selectedPhoto = new ClientPrintsSelection(); $selectedPhoto->print_order_id = $order->id; $selectedPhoto->client_album_photo_id = $photo["photo_id"]; $selectedPhoto->format_id = $photo["format_id"]; $selectedPhoto->quantity = $photo["quantity"]; $selectedPhoto->save(); } Mail::send('emails.admin_order_notification', [], function ($message) { $message->to(Config::get('constants.site.OWNEREMAIL'), Config::get('constants.site.OWNERNAME'))->subject('Prints Order Received'); }); }