How to use php arrow function in Laravel web.php Route

Viewed 3305

hi I want to use this in laravel

Route::get('/a',fn() => view('a'));

instead of :

Route::get('/a', function () {
    return view('a');
});

but it doesn't work

1 Answers

I tried Route::get('/a',fn() => view('welcome')); and worked fine.

Did you check that the view 'a' exists?

Give more detail of the error. Maybe is something else that is not working.

Related