<?php /* |-------------------------------------------------------------------------- | 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. | */ use App\Local; Route::get('/', function () { return view('welcome'); }); Route::get('/locais/gerar', function () { for ($i = 0; $i < 100; $i++) { Local::create(['id' => 0, 'codigo_local' => rand(1, 999999), 'pais' => str_random(10), 'estado' => str_random(10), 'cidade' => str_random(10)]); } }); Route::get('/locais/listar', function () { $locais = Local::all(); foreach ($locais as $local) { echo $local->codigo_local . '-' . $local->pais; echo '<br/>'; } });
/** * Display a listing of the resource. * * @return Response */ public function index() { return ['locais' => \App\Local::all()]; }