Skip links

Calling a Laravel Controller Method to another Controller.

I found this snippet on Stack Overflow. Usually I don’t share content from other sites, but this was something most people need.

use App\Http\Controllers\OtherController;

class TestController extends Controller
{
    public function index()
    {
        //Calling a method that is from the OtherController
        $result = (new OtherController)->method();
    }
}

2) Second way

app('App\Http\Controllers\OtherController')->method();

Both way you can get another controller function.

Link – https://stackoverflow.com/questions/31948980/how-to-call-a-controller-function-in-another-controller-in-laravel-5/31949144

Leave a comment