/**
  * 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 a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     // Return all Artworks
     $term = $request->input('query');
     $dbField = $request->input('dbField');
     $sortBy = $request->input('sortBy');
     if (is_null($sortBy)) {
         $sortBy = 'artist_lastname';
     }
     if (is_null($term)) {
         $term = '';
     }
     if (is_null($dbField)) {
         $dbField = 'artist_lastname';
     }
     if (isset($term)) {
         $artworks = Artwork::where(strtolower($dbField), 'LIKE', '%' . $term . '%')->orderBy($sortBy, 'asc')->get();
     } else {
         $artworks = Artwork::all();
     }
     return view('artworks.index')->with('artworks', $artworks);
 }
 /**
  * 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.');
     }
 }
 /**
  * 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 #7
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $artworks = Artwork::where('user_id', Auth::user()->id)->get();
     return view('backend.artwork.index', compact('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);
     }
 }