hello i'm new to laravel and maybe this is silly for you guys out here. in laravel 8 routing web.php i've created a route like this:
Route::get('/', function () {
return view('login');
});
Route::post('/auth', 'App\Http\Controllers\SiteController@auth');
Route::get('/home', function () {
if (session()->has('username')) return view('home');
else return redirect('/');
});
Route::post('/editprofile', 'App\Http\Controllers\SiteController@edit_profile');
what i want to ask is, can we return the controller from callback like view as well? let's say i want to check the session when user edit his profile. so in route /editprofile, the second parameter isn't 'App\Http\Controllers\SiteController@edit_profile', but a callback function like route '/home'. like this:
Route::post('/home', function () {
if (session()->has('username')) return controller('App\Http\Controllers\SiteController@edit_profile');
else return redirect('/');
});
but it returns error haha. let's say i don't want to use the __construct method to check session. is it possible? thanks in advance