route name laravel 8 code example

Example 1: laravel is route name

// Check if route is ***
Request::route()->named("YourRouteNameView")

Example 2: set route name laravel

Route::get('/novanoticia', 'HomeController@getNovaNoticia')->name('route_name');
Route::get('/novanoticia', ['as' => 'route_name', 'uses' => 'HomeController@getNovaNoticia']);

Example 3: laravel 8 routes namespace

Route::group(['namespace' => 'App\Http\Controllers', 'prefix' => 'admin',
 'as' => 'admin.', 'middleware' => ['auth:sanctum', 'verified']], function()
{
    Route::get('/dashboard', ['DashboardController', 'index']);
});

Example 4: laraval routing

Route::redirect('/here', '/there', 301);

Example 5: set route name laravel

Route::get('/novanoticia', 'HomeController@getNovaNoticia')->name('route_name');

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();
        });