call route laravel code example
Example 1: call laravel route js
function confirmDelete(id){
let url = "{{ route('getDeleteRequest', ':id') }}";
url = url.replace(':id', id);
document.location.href=url;
}
Example 2: laravel get route
Route::get('foo', function () {
return 'Hello World';
});
Example 3: laravel get route
Route::get('/user', 'UserController@index');
Example 4: 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 5: laravel route
Route::view('/welcome', 'welcome');
Route::view('/welcome', 'welcome', ['name' => 'Taylor']);