Laravel 03
Laravel 03
=================
1. Laravel Routing- Basic Routing and Redirect Routes :-
---------------------------------------------------------
1. What is Routing ?
--> Laravel routes are used to bind URL to controller action.
--> When you create new pages in Laravel you have to remember
three things :-
a. you first decide, what would be the URL that user will access
via browser?
b. How you can bind this URL with a specific controller methods?
3. Routing Types :-
a. Basic Routing
b. Redirect Routes
c. View Routes
d. Route Parameters
e. Named Routes
f. Route Caching
a. Basic Routing :-
Route ::get('/greeting',function(){
return "Hello World";
});
b. Redirect Routes :-
1. Route::redirect('/here','there');
2. Route::redirect('/here', '/there', 301);
3. Route::permanentRedirect('/here', '/there');
===================================================================================
===================
2. Laravel Routing - View Routes, Route Parameters, Named Routes,Route Caching :-
----------------------------------------------------------------------------------
c. View Routes :-
1. Route::view('/welcome','welcome');
3. Route::get('/', function () {
return view('welcome');
});
d. Route Parameters :-
Route::get('/user/{name}',function($name){
return 'User : '.$name;
});
OR
Route::get('/user/{id}',function($id){
return 'User : '.$id;
});
OR
Route::get('/user/{fname}/{lname}',function($fname,$lname){
return 'User : '.$fname.' '.$lname;
});
e. Named Routes :-
Route::get('/users/profile', function () {
// ....
})->name('profile');
OR
Route::get('/users/profile',[UserProfileController::class,'show'])-
>name('profile')
f. Route Caching :-
1. php artisan route:cache
2. php artisan route:clear
===================================================================================
===================
3. Assignment : Laravel Routing :-
----------------------------------
1. Create view Routes with the URL about, contact and home.
2. Create three different views withe fake data for the said routes.
3. Create routes with parameters and pass and print the same parameter
in the views.
4. Create a routes with parameters, if Parameters value is LearnVern
then redirect the same route on learnvern.com