WEB DEVELOPER SITE
TUTORIALS HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Laravel Redirections


Laravel - Redirections : Named course is utilized to give explicit name to a course. The name can be relegated utilizing the as cluster key.

Route::get('user/profile', ['as' => 'profile', work () { 

/ 

}]); 

Note − Here, we have given the name profile to a course user/profile.

Redirecting to Named Routes

Example

Observe the accompanying guide to see increasingly about Redirecting to named courses −

Step 1 − Create a view called test.php and spare it at

resources/sees/test.php.

<html> 

<body> 

<h1>Example of Redirecting to Named Routes</h1> 

</body> 

</html>

Step 2 − In routes.php, we have set up the course for test.php record. We have renamed it to testing. We have additionally set up another course redirect which will divert the demand to the named course testing.

app/Http/routes.php

Route::get('/test', ['as'=>'testing',function(){ 

return view('test2'); 

}]); 

Route::get('redirect',function(){ 

return divert()- >route('testing'); 

}); 

Step 3 − Visit the accompanying URL to test the named course example.

http://localhost:8000/divert 

Step 4 − After execution of the above URL, you will be diverted to http://localhost:8000/test as we are diverting to the named course testing.