Friends, if there is anything most useful in the Laravel website, then it is our controller, which has to handle HP operations, HP queries and along with that, we have to take care that there is no such thing as hacking and at the same time, the speed of our website should also be very high and should not show any error or bugs.
Friends, with the help of controller, we can perform current operation very easily inside Laravel. We connect the controller to the model or sometimes it also happens that we do not need to connect to the model and can communicate to database by using controller.
To understand the controller properly, please watch our YouTube video once, you will clearly understand everything.
This is how to create a controller in Laravel using the command prompt:
php artisan make:controller
web.php (router/web.php)
use App\Http\Controllers\Crudcontroller;
Route::get('mycontroller', [Crudcontroller::class, 'myfun']);
Crudcontroller.php (app/http/controllers/Crudcontroller.php)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Crudcontroller extends Controller
{
function myfun(){
echo 'hi this is controller';
}
}