Example #1
0
 public function index()
 {
     //scope
     //$films = Film::orderBy('date', 'asc')->released()->get();
     //without scope
     //$films = Film::orderBy('date', 'asc')->where('date', '>=', Carbon::now())->get();
     $films = Film::orderBy('date', 'asc')->take(10)->get();
     return view('main', compact('films'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $films = Film::orderBy('title', 'asc')->get();
     return view('films.index', compact('films'));
 }
Example #3
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'));
});