PrevailExcel / laraquizbot

A Bot built with Laravel 8 and BotMan 2 that runs on Telegram for quiz on different tracks like Laravel, React, Django and more.
2 stars 3 forks source link

How Implement Middleware In laravel 11 #1

Open Milad-jfr opened 1 month ago

Milad-jfr commented 1 month ago

How implement Middleware lines in Laravel 11 , on BotManController.php :

use App\Http\Middleware\PreventDoubleClicks;
$botman->middleware->captured(new PreventDoubleClicks);

Lines above not working because Laravel 11 does not have Middleware Folder like older versions

PrevailExcel commented 3 days ago

Laravel implements Middlewares a bi differently from the older versions.

To add midddlewares in Laravel 11, you have to add it inside the bootstrap/app.php file.

->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: [
        'botman',
    ]);

   //add your custom middlewares here.
})