Lectures List
capscom technology computer course almora

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

app/Http/Controllers

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);
Author/Written by: Mr Hemant Singh (Founder)
Terms & Conditions CAPSCOM TECHNOLOGY Pvt. Ltd. का बेहतर रूप से संचालन करने के लिए यहॉ कुछ नियमें और शर्ते लागू है अगर आप कैप्सकॉम टैक्नोलॉजी में पढ़ रहे है तो यह आप पर लागू होता है।