Exemplo n.º 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     // $genres = DB::table('genres')
     //                 ->orderBy('name', 'asc')
     //                 ->lists('name','id');
     $genres = Genre::orderBy('name', 'asc')->get();
     return view('films.create', compact('genres'));
 }
Exemplo n.º 2
0
<?php

use App\Film;
use App\Genre;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Route::resource('films', 'FilmsController');
Route::get('/', function () {
    $films = Film::orderBy('title', 'asc')->with('genres')->get();
    $genres = Genre::orderBy('name', 'asc')->get();
    return view('list', compact('films', 'genres'));
});
Exemplo n.º 3
0
 public function getGenres()
 {
     $genres = Genre::orderBy('name')->get();
     return view('genres', ['genres' => $genres]);
 }
Exemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     $out = ['form_route' => ['route' => ['track.update', $id], 'method' => 'PUT', 'class' => 'form-horizontal'], 'artist_credit' => []];
     $out['track'] = Track::findOrNew((int) $id);
     $out['genre'] = Genre::orderBy('id')->lists('name', 'id');
     if (count(Request::old())) {
         $old = Request::old();
         $out['release'] = Release::find($old['release_id']);
         if (isset($old['artist_credit']['id'])) {
             foreach ($old['artist_credit']['id'] as $n => $ac_id) {
                 $artist = Artist::where('id', $ac_id)->firstOrFail();
                 if (count($artist)) {
                     $out['artist_credit'][$n]['name'] = $artist->name;
                     $out['artist_credit'][$n]['work_type_id'] = $old['artist_credit']['work'][$n];
                     $out['artist_credit'][$n]['join_phrase'] = $old['artist_credit']['join'][$n];
                     $out['artist_credit'][$n]['artist_id'] = $old['artist_credit']['id'][$n];
                 }
             }
         }
     } else {
         $out['release'] = $out['track']->release;
         $out['artist_credit'] = $out['track']->credit->credit_name;
     }
     $out['work_type'] = WorkType::all();
     $out['genres_selected'] = [];
     foreach ($out['track']->genres as $row) {
         $out['genres_selected'][] = $row->id;
     }
     return view('tracks.form', $out);
 }