/** * Remove the specified portfolio album from storage. * * @param int $id * @return Response */ public function destroy($id) { $portfolio = PortfolioAlbum::find($id); //delete folder and Photos from server $this->dispatch(new DeleteFolderFileCommand(public_path("assets/images/portfolio_albums/" . $id))); //delete from database PortfolioAlbumPhoto::where("portfolio_album_id", "=", $id)->delete(); $portfolio->delete(); return redirect('/admin/dashboard/portfolio')->with('message', FlashMessage::DisplayAlert('Successfully deleted album!', 'success')); }
/** * 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'); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(ContactRequest $request, $id) { $this->dispatch(new ContactCommand($id, $request->title, $request->address, $request->city, $request->state, $request->zip, $request->email, $request->phone)); return redirect()->back()->with('message', FlashMessage::DisplayAlert('Successfully updated!', 'success')); }
/** * 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')); } }
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'); }); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(AboutRequest $request, $id) { $this->dispatch(new AboutCommand($id, $request->title, $request->body)); return redirect()->back()->with('message', FlashMessage::DisplayAlert('Successfully updated!', 'success')); }