Пример #1
0
 /**
  * Display the listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $genres = Genres::all();
     $user = $this->checkUserDetails();
     return view('admin.genres', compact('genres', 'user'));
 }
Пример #2
0
 /**
  *
  * Show form to edit existing movie
  * @param integer $movie_id
  * @return Response
  *
  */
 public function edit($movie_id)
 {
     if (!$this->isAdmin) {
         return view('auth.login');
     }
     Session::put('movie_id', $movie_id);
     $movie = Movies::findorfail($movie_id);
     $movie->genres;
     $movie->purchased = date("d-m-Y", strtotime($movie->purchased));
     $movie->cover = $this->checkImageExists($movie->image, $movie->sort_name, 'covers');
     $movie->cover_count = strlen($movie->cover);
     $values = json_decode($movie);
     $movie->genres = DB::table('categories')->where('movie_id', $movie_id)->lists('genre_id');
     $movie->tags = DB::table('tags')->where('movie_id', $movie_id)->lists('keyword_id');
     $fields = Forms::getFormFields('create_movie', true);
     $app = app();
     $options = $app->make('stdClass');
     $options->movies = Movies::orderBy('sort_name')->lists('name', 'movie_id')->toArray();
     $options->certificates = Certificates::lists('title', 'certificate_id')->toArray();
     $options->studios = Studios::orderBy('name', 'asc')->lists('name', 'studio_id')->toArray();
     $options->formats = Formats::lists('type', 'format_id')->toArray();
     $options->actors = Persons::select(DB::raw("CONCAT(forename, ' ', surname) AS full_name"), 'person_id')->whereNotIn('person_id', function ($query) use($movie_id) {
         $query->select('person_id')->from('cast')->where('movie_id', $movie_id);
     })->orderBy('forename')->lists('full_name', 'person_id')->all();
     $options->crew = Persons::select(DB::raw("CONCAT(forename, ' ', surname) AS full_name"), 'person_id')->orderBy('forename')->lists('full_name', 'person_id')->all();
     $options->keywords = Keywords::orderBy('word')->get();
     foreach ($options->keywords as $keyword) {
         $keyword->selected = in_array($keyword->keyword_id, $movie->tags) ? true : false;
     }
     $options->genres = Genres::all();
     foreach ($options->genres as $genre) {
         $genre->selected = in_array($genre->genre_id, $movie->genres) ? true : false;
     }
     $user = $this->isAdmin;
     return view('movies.edit', compact('movie', 'fields', 'values', 'options', 'user'));
 }