laravel route group controller code example
Example 1: laravel route namespace and prefix
Route::prefix('admin')->group(function () {
Route::get('/users', function () {
});
});
Example 2: group routes in laravel
Route::middleware(['first', 'second'])->group(function () {
Route::get('/', function () {
});
Route::get('/user/profile', function () {
});
});
Example 3: laravel group routes
Route::group(['prefix' => 'admin'], function () {
Route::get('users', function () {
});
});
Example 4: route group in laravel
Route::group(['prefix' => 'admin']){
Route::get('/',function(){
});
}
Example 5: laravel route
Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');
Example 6: comment = Comment::find($this->route('comment')); in laravel
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onCascade('update')->onDelete('cascade');
$table->integer('post_id')->unsigned();
$table->foreign('post_id')->references('id')->on('users')->onCascade('update')->onDelete('cascade');
$table->text('comment');
$table->timestamps();
$table->rememberToken();
});