mardi 15 mai 2018

Route variable not working

Why doesn't this simple route work?

Route::get('/test/{id?}', function ($id = 1) {
    return view('test');
});

This is the content in "test" view (test.blade.php):

This is a test: .

If I enter:

http://laravel.test/test

or

http://laravel.test/test/1

I always get this error:

This is a test: <?php echo e($id); ?>.

"Undefined variable: id (View: /home/vagrant/code/test/resources/views/test.blade.php)"



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire