Reputation: 684
Question:
How to get the "current Controller
" in a view, that is "Processing" the Request respectively triggering/calling the View. (Beside passing an instance to the view via parameter)?
Is there some "current global Context" similar to Request
that I can get like Controller::instance() or similiar?
Upvotes: 3
Views: 739
Reputation: 41360
From the Application
$controller = app(\Illuminate\Routing\Route::class)->controller;
And also, there is a nicer way
$controller = request()->route()->controller;
Tested on Laravel 7.29.3
Upvotes: 2