laravel delete route code example

Example 1: laravel form method delete

// Blade
@method('delete')

// Html
<input type="hidden" name="_method" value="delete">

Example 2: delete route method in laravel

<form method="POST" action="{{ route('route.name', [ 'id'=> $item->id ]) }}">
              @csrf
              <input type="hidden" name="_method" value="DELETE">
              <button type="submit" class="btn btn-danger btn-icon">
                <i data-feather="delete"></i>
              </button>
            </form>

Example 3: laravel routes return view in web.php

Route::get("/page", function(){
   return View::make("dir.page");
});

Example 4: laravel route match

Route::match(['get', 'post'], '/', function () {
    //
});

Route::any('/', function () {
    //
});

Example 5: laravel route

Route::view('/welcome', 'welcome');

Route::view('/welcome', 'welcome', ['name' => 'Taylor']);

Example 6: set route name laravel

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