डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

Controllers at Laravel 9

We can not write all the logics at the route every time.
we can make group of functions of same login as a single user, so that we can use controllers at laravel.

Controllers are stored at


Load and Share data to view

public function users(){
return view('user.login',['message'=>'Login'])'

Create route for laravel request

use App\Http\Controllers\UserController;
Route::get('login', [ UserController::class, 'login' ]);

Sometime some common controller has same task to create, delete, edit and show records, to repeat same task for every controller we can use resource controller.

Resource Controller

php artisan make:controller AdminController --resource

Route for resource controller

use App\Http\Controllers\AdminController;
Route::resource('admin', AdminController::class);

As we added all routes using a single resource route, for confirmation we can check all the list of routes using a given command.

php artisan route:list

Create API Controller

php artisan make:controller ProductController --api

API Resource routes

Route::apiResources('products', ProductControllers::class);
© 2016 - 2023, All Rights are Reserved.