Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Laravel: Load method in another controller without changing the url

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.18k
    Comment on it

    We can load method in another controller without changing the url using Laravel.

    If you are using Laravel 3 then we will define:

    Controller::call('ApplesController@getSomething');
    

    If We are using Larval 4.x then we will define:

    $request = Request::create('/apples', 'GET', array());
    return Route::dispatch($request)->getContent();
    

    In this case, you have to define a route for ApplesController, something like this

    Route::get('/apples', 'ApplesController@getSomething'); // in routes.php
    

    In the array() you can pass arguments if required.

    By this way we will load method in another controller without changing the url using Laravel 4.x

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: