D
D
denis_213213212020-04-26 15:00:59
Laravel
denis_21321321, 2020-04-26 15:00:59

How to display additional text in a template through middleware?

When you go to a certain page, the request goes through the middleware auth , is it possible to make it so that if the check fails, it does not just return the template, but also in a certain place, for example, the text "First, you need to register"

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
    protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            return route('welcome');
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question