/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::statement('SET FOREIGN_KEY_CHECKS = 0'); DB::table('leerling')->truncate(); DB::table('klas')->truncate(); factory(Klas::class, 50)->create(); factory(Leerling::class, 50)->create(); $leerling = Leerling::find(rand(1, 50)); $klas = Klas::find(rand(1, 50)); //var_dump($klas); DB::statement('SET FOREIGN_KEY_CHECKS = 1'); Model::reguard(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $leerlingen = Leerling::all(); return view('leerling.index', ['leerlingen' => $leerlingen]); }
<?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 Eduweb2\lvslib\Leerling; use Eduweb2\lvslib\Klas; Route::get('/', function () { $leerlingen = Leerling::all(); //var_dump($leerlingen); return View::make('leerlingen')->with('leerlingen', $leerlingen); });