Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

what is invokable controller in laravel

@CodeGrepperManu answered on April 15, 2023 Popularity 9/10 Helpfulness 4/10

Contents


More Related Answers

  • laravel create controller
  • laravel module create controller
  • how to create controler in laravel
  • laravel create controller command
  • laravel controller store
  • laravel access controller method from another controller
  • create controller laravel with model
  • create controller in laravel
  • make controller and model laravel
  • types of controller in laravel
  • how to create a controller in laravel
  • make controller and model laravel
  • laravel sample controller
  • make controller and model laravel
  • make controller and model laravel
  • create controller in laravel 9 with model
  • make controller and model laravel
  • make:controller in laravel 8
  • make controller and model laravel
  • php artisan make view controller with methods
  • Create Model with Controller in Laravel
  • create controller command in laravel
  • how to make controller in laravel
  • make controller and model laravel
  • How to use function in controller in blade
  • laravel make controller
  • make controller and model laravel
  • laravel controller show
  • make controller and model laravel
  • make controller and model laravel

  • what is invokable controller in laravel

    3

    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');


    Popularity 9/10 Helpfulness 4/10 Language php
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Apr 15 2023
    @CodeGrepperManu
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.