Open a view from another

2

In my login.blade.php view I have:

    <div class="container" id="forgot">
        <a href="" id="text-forgot">RECUPERA TU CONTRASEÑA</a>
    </div>

How do I make that from that href open my other view mail.blade.php?

I saw something like {route: :( view)} but it did not work for me.

    
asked by Naoto Amari 26.02.2018 в 00:35
source

1 answer

2

The simplest and most recommended way by laravel, assuming that it is a static view and you want to call it directly (without processing in the controller or similar), would define a direct route to the view, and assign it a name:

Route::view('reiniciar-clave', 'email')->name('reset-password');

However, if you have a route that uses a controller method, you define it with its corresponding verb:

Route::get(...)->name('reset-password');

The documentation: link

And to call the route by name (recommended practice in Laravel), you use the helper route:

<a href="{{ route('reset-password') }}" id="text-forgot">RECUPERA TU CONTRASEÑA</a>

Your documentation: link

Why is it a bad practice to use the helper url () and is it recommended to use the name of the route?

If someday you decide that the url is not called reiniciar-clave but nueva-contrasena , you do not have to search through all the files of your project to change this text.

    
answered by 26.02.2018 / 00:49
source