Ejemplo n.º 1
0
/*
|--------------------------------------------------------------------------
| 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 Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
    $stops = Stop::orderBy('name')->get(array('name', 'id'));
    return View::make('hello')->with(array('stops' => $stops));
});
Route::get('/stop/{id}', function ($id) {
    $stop = Stop::find($id);
    $sum = 0;
    $max = 5;
    if ($stop) {
        $buses = $stop->buses;
        foreach ($buses as $bus) {
            $weekend = date('N', strtotime(date('now'))) >= 6;
            $now = new DateTime('now');
            $timetables = $bus->timetables;
            foreach ($timetables as $timetable) {
                if ($sum == $max) {
                    break;
                }
                $bus_time = new DateTime($timetable->time);
                if ($bus_time > $now) {
                    if ($weekend && $timetable->type == 'working_day') {