![](https://www.theaiops.com/wp-content/uploads/2022/12/image-44-1024x545.png)
The controller interacts with the model and the view. It means we write business logic in the controller
Make a Controller
StudentsController.php
Code
php artisan make:controller StudentsController
Result
![](https://www.theaiops.com/wp-content/uploads/2022/12/image-48-1024x496.png)
Call with routine
web.php
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get("users", 'StudentsControllers@index');
![](https://www.theaiops.com/wp-content/uploads/2022/12/image-49-1024x532.png)
Pass Parameter
StudentController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserControllers extends Controller
{
public function index($id)
{
echo $id;
}
}
Results:
![](https://www.theaiops.com/wp-content/uploads/2022/12/image-47-1024x544.png)