/**
  * Display the specified resource.
  *
  * @param  string  $slug
  * @return Response
  */
 public function show($slug)
 {
     // Does this user exist?
     if (User::where('slug', $slug)->first()) {
         // Check if the user is linked to an artist and get the artworks
         $user = User::where('slug', $slug)->first();
         $artist = Artist::where('user_id', $user->id)->first();
         if ($artist != null) {
             if ($artist->user_id != 0) {
                 $artworks = Artwork::where('artist', $artist->id)->get();
             } else {
                 $artworks = [];
             }
         } else {
             $artworks = [];
         }
         // Am i this user?
         if (Auth::check() && User::where('slug', $slug)->first()->id == Auth::user()->id) {
             return View::make('users/showself', compact('user', 'artworks'));
         } else {
             return View::make('users/show', compact('user', 'artworks'));
         }
     } else {
         return Redirect::to('/');
     }
 }
 public function index()
 {
     $artworks = Artwork::where(['state' => 0])->orderBy('id', 'DESC')->take(12)->get();
     $artCount = Artwork::where('state', 0)->count();
     TagsHelper::addTagsToCollection($artworks);
     return View::make('index', compact('artworks', 'artCount'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($tag)
 {
     $articles = News::withAnyTag($tag)->get();
     $artworks = Artwork::withAnyTag($tag)->get();
     $events = Event::withAnyTag($tag)->get();
     return View::make('tags/show', compact('articles', 'artworks', 'events', 'tag'));
 }
Beispiel #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|unique:auctions|max:255', 'artist' => 'required|max:255', 'year' => 'required|integer|digits_between:3,4|max:2016', 'width' => 'required|numeric', 'height' => 'required|numeric', 'depth' => 'numeric', 'description' => 'required|max:255', 'condition' => 'required|max:255', 'origin' => 'required|max:255', 'picture' => 'required', 'minprice' => 'required|numeric|', 'buyout' => 'required|numeric|greater_than_field:minprice', 'date' => 'required|date|after:today', 'terms' => 'required|accepted']);
     $artist = Artist::where('name', $request->artist)->first();
     if (!$artist) {
         $artist = new Artist(['name' => $request->artist]);
     }
     $artist->save();
     $auction = new Auction(['title' => $request->title, 'description' => $request->description, 'start' => Carbon::now(), 'end' => $request->date, 'buy_now' => $request->buyout, 'price' => $request->minprice, 'status' => 'Active', 'style_id' => Style::Where('name', $request->style)->first()->id]);
     $artwork = new Artwork(['name' => $request->title, 'width' => $request->width, 'height' => $request->height, 'depth' => $request->depth, 'condition' => $request->condition, 'origin' => $request->origin, 'year' => $request->year]);
     $auction->save();
     $artwork->auction()->associate($auction);
     $artwork->save();
     // Picture save
     $imageName = $artwork->id . '.' . $request->file('picture')->getClientOriginalExtension();
     $artwork->image = $imageName;
     $request->file('picture')->move(base_path() . '/public/img/', $imageName);
     $artist->artworks()->save($artwork);
     $owner = $request->user();
     $owner->auctionsowner()->save($auction);
     return redirect('/auctions/' . $owner->id);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     // request search query term & field for search
     $term = $request->input('query');
     $dbField = $request->input('dbField');
     $sortBy = $request->input('sortBy');
     if (is_null($sortBy)) {
         $sortBy = 'artist_fullname';
     }
     if (isset($term)) {
         if ($dbField == 'artist_lastname') {
             $artworks = Artwork::where(strtolower($dbField), 'ILIKE', '' . $term . '%')->orderBy($sortBy, 'asc')->get();
         } elseif ($dbField == 'art_fair_year') {
             $artworks = Artwork::where(strtolower($dbField), 'ILIKE', '%' . $term . '%')->orderBy($sortBy, 'asc')->get();
         } else {
             $artworks = Artwork::where(strtolower($dbField), 'ILIKE', '%' . $term . '%')->orderBy($sortBy, 'asc')->get();
         }
     } else {
         $artworks = Artwork::all();
     }
     // Pass in articles data to view
     return view('search.index', ['artworks' => $artworks]);
 }
 public function update($id)
 {
     $filterItem = filter_optie::findOrFail($id);
     $filterItemBefore = $filterItem->naam;
     $filterItem->naam = Input::get('naam');
     if ($filterItem->filter_id == 1) {
         $column = "category";
     } elseif ($filterItem->filter_id == 2) {
         $column = "genre";
     } elseif ($filterItem->filter_id == 3) {
         $column = "technique";
     } elseif ($filterItem->filter_id == 4) {
         $column = "material";
     } elseif ($filterItem->filter_id == 5) {
         $column = "colour";
     }
     if ($filterItem->save()) {
         Artwork::where($column, $filterItemBefore)->update([$column => $filterItem->naam]);
         return redirect('filters/' . $filterItem->filter_id)->with('succesMsg', '<span class="glyphicon glyphicon-ok"></span> Het item <b>' . $filterItemBefore . '</b> is succesvol gewijzigd naar <b>' . $filterItem->naam . '</b>.');
     } else {
         return redirect('filters/' . $filterItem->filter_id)->with('errorMsg', '<span class="glyphicon glyphicon-ok"></span> Er is helaas iets fout gegaan. Probeer het nog een keer.');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $allReservations = DB::table('reservations')->where('artwork_id', '=', Input::get('artwork-id'))->get();
     $reservation = new Reservation();
     $reservation->user_id = Auth::user()->id;
     $reservation->artwork_id = Input::get('artwork-id');
     $reservation->from_date = Input::get('from-date');
     $reservation->to_date = Input::get('to-date');
     $reservation->delivery_adress = Input::get('delivery_adress');
     $artwork = Artwork::findOrFail(Input::get('artwork-id'));
     $overlap = false;
     foreach ($allReservations as $key) {
         if (Input::get('from-date') < $key->to_date && Input::get('from-date') > $key->from_date) {
             $overlap = true;
         } elseif (Input::get('to-date') > $key->from_date && Input::get('to-date') < $key->to_date) {
             $overlap = true;
         } elseif (Input::get('from-date') == $key->from_date) {
             $overlap = true;
         }
     }
     if (!$overlap) {
         $artwork->reserved += 1;
         $reservation->save();
         $artwork->update(['reserved' => $artwork->reserved]);
         return Response::json([0 => 'Reservering geslaagd. Klik <a href="/gallery">hier</a> om terug te gaan'], HttpCode::Ok);
     } else {
         $latest = "";
         foreach ($allReservations as $key) {
             if (is_null($latest)) {
                 $latest = $key->to_date;
             } elseif ($key->to_date > $latest) {
                 $latest = $key->to_date;
             }
         }
         return Response::json([0 => 'Het kunstwerk is al gereserveerd op deze datum.'], HttpCode::Conflict);
     }
 }
 public function archivedArtworks()
 {
     $artworks = Artwork::whereState(1)->get();
     TagsHelper::addTagsToCollection($artworks);
     return Response::json($artworks->reverse(), 200);
 }
 /**
  * Remove the specified artist from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Auth::check() && Auth::user()->hasOnePrivelege(['Administrator'])) {
         $artist = Artist::findOrFail($id);
         if (Input::get('delete') == "delete") {
             $artist->delete();
         } elseif (Input::get('delete') == "deleteAll") {
             $artworks = Artwork::where('artist', $id)->delete();
             $artist->delete();
         } else {
         }
         return redirect('/artists');
     } else {
         return View::make('errors/' . HttpCode::Unauthorized);
     }
 }
Beispiel #10
0
 /**
  * Add image to the artwork with the id of $id
  * 
  * @param Request   $request 
  * @param int       $id
  */
 public function addArtworkImage(Request $request, $id)
 {
     $this->validate($request, ['image' => 'required|mimes:jpg,jpeg,png,bmp']);
     $artwork = Artwork::find($id);
     $media = $artwork->addArtworkImage($request->image);
     if ($media) {
         return response()->json(array('media' => $media, 'path' => $artwork->getArtworkImageUrl()), 200);
     } else {
         return response()->json(false, 500);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $artwork = Artwork::find($id);
     $artwork->delete();
     return redirect('/artworks');
 }
 public function showArchived()
 {
     if (Auth::check() && Auth::user()->hasOnePrivelege(['Moderator', 'Administrator'])) {
         $artworks = Artwork::where(['state' => 1])->get();
         $artCount = Artwork::where('state', 1)->count();
         TagsHelper::addTagsToCollection($artworks);
         return View::make('gallery/archive', compact('artworks', 'artCount'));
     } else {
         return View::make('errors/' . HttpCode::NotFound);
     }
 }