laravel routing
xxxxxxxxxx
# laravel routing
Route::post('/registration/store',[AuthenticationController::class,'store']); //v.8.0 - v.10
Route::get('/user', 'UserController@index'); //v.7.0
#group in routing
Route::group(['prefix'=>'accounts','as'=>'account.'], function(){
Route::get('/', 'AccountController@index')->name('index');
Route::get('connect', 'AccountController@connect')->name('connect');
});
xxxxxxxxxx
use App\Http\Controllers\UserController;
use App\Models\User;
// Route definition...
Route::get('/users/{user}', [UserController::class, 'show']);
// Controller method definition...
public function show(User $user)
{
return view('user.profile', ['user' => $user]);
}
xxxxxxxxxx
Route::view('Url','PageName');
//here Url is the call word which pass from url
Route::get('Url',[Controller::class ,'FunctionName']);
//from this route you can access function of specific
//controller thourgh specific url route
Route::get('Url/{id}',[Controller::class ,'FunctionName']);
//if you want to pass specific id or any thing thorugh route you
//can use it{id} or{name} or {anything} means anything you want to access
xxxxxxxxxx
use Illuminate\Support\Facades\Route;
Route::get('/greeting', function () {
return 'Hello World';
});
xxxxxxxxxx
Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');
xxxxxxxxxx
Route::get('user/{id}/profile', function ($id) {
//
})->name('profile');
$url = route('profile', ['id' => 1, 'photos' => 'yes']);
// /user/1/profile?photos=yes
xxxxxxxxxx
Route::view('/welcome', 'welcome');
Route::view('/welcome', 'welcome', ['name' => 'Taylor']);