what is invokable controller in laravel?
__invoke function is kind of magic method, call automatically we try to call an object as a function.
here no need to write separate routes for all pages eg: careers, aboutus, contactus
Laravel provide a single action controller called invokable controller which contains a invoke method to perform a single task. So for doing only single task we can use this invokable controller.
use App\Http\Controllers\SitePageController;
Route::get('careers', [SitePageController::class], 'careers']);
Route::get('aboutus',[SitePageController::class], 'aboutus']);
Route::get('contactus', [SitePageController::class, 'contactus']);
single controller can handling all those routes/requests.
Route::get('/{pages}','SitePageController')
->name('page')
->where('pages','careers|aboutus|contactus');