php artisan make route code example
Example 1: laravel show routes artisan
php artisan route:list
Example 2: laravel route controller
use App\Http\Controllers\UserController;
Route::get('user/{id}', [UserController::class, 'show']);
Example 3: how to create controller in laravel
Simple controller:
php artisan make:controller nameOfController
Want to create controller in a folder? use it like this:
php artisan make:controller NameOfFolder/nameOfController
Resource Controller:This controller will create all CRUD methods
php artisan make:controller nameOfController --resource
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 8 Resource
php artisan make:controller BlogController --resource
Example 6: how to create route in laravel
Route::match(['get', 'post'], '/', function () {
//
});