Answer the question
In order to leave comments, you need to log in
How to intercept all url requests in Laravel?
Good day. The task is this: when a person goes to any page of the site, you need to check him for authorization, and if he is not authorized, then send him to the authorization page, I thought to do everything through Route:: get ... But apparently this will not work, in general prompt in what direction to dig?
Answer the question
In order to leave comments, you need to log in
In short, I solved everything this way: I
created a 404 page by changing the 'render' function along the app/Exceptions/Handler.php path and wrapped all the necessary links in a group, as suggested earlier. Thanks for the help, good luck to everyone :)
If anyone needs it, keep the function:
public function render($request, Exception $e)
{
//customize 404 page
if ($this->isHttpException($e)) {
$statusCode = $e->getStatusCode();
switch ($statusCode) {
case '404':
//Страница берется из директории resources/views
return response()->view('notfound');
}
}
return parent::render($request, $e);
}
Route::group(['middleware' => ['auth']], function() {
// тут все ваши роуты
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question