I'm making an Ajax call from a default Blade layout, shared by all the pages. The Ajax call is handled in AjaxController
and the controller needs to know "what" is calling it.
Normally, I would do the following to check the current route:
$request->route()->getActionName(); // => e.g. "AjaxController@index"
But how do I retrieve the action name of a page from which the ajax call was made? So:
- Ajax call is made from page A to controller X
- Controller X checks what the route name of page A is
In the end, I can always pass the caller route name with the Ajax call, but I'm wondering if there's a way to know the caller from within the AjaxController
.