Routing types
We'll start with the basics and gradually move towards advanced routing techniques, providing you with a comprehensive understanding of Laravel's routing capabilities. So, stay tuned and take your Laravel skills to the next level!
Primary Route
Basic Route
Default Route Files
Redirect Routes
View Routes
Route list
Basic Route
//Write this code in laravel Project[Resources/routes/web.php]
//Route below will return you Hello World
Route::get('/greeting', function () {
return 'Hello World';});
Default Route Files
Routes/web.php ->defines = interface and assigned to web middleware group.[web-middleware provides session states and CSRF]
Routes/api.php -> are stateless and are defined in the route service provider [/api prefix is automatically added] ->routeserviceprovider helps API route to carry its functions out
Redirect Routes
Route::redirect('/here', '/there');
//Route::redirect('uri', 'destination');
Route::permanentRedirect('/here', '/there');//Code will be 302=means resources is moved to url header.
Route::redirect('/here','/there',302);
Route view
Route::view('/welcome', 'welcome', ['name' => 'Taylor']);
//name=>'Taylor is an array'
Route list
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);