Get Laravel 5 controller name in view -


our old website css set body tag had id of controller name , class of action name, using zend framework 1. we're switching laravel 5. found way action name through route class, can't find method controller name. don't see in laravel docs this. ideas?

this how action. inject route class, , call:

$route->getactionname().

i'm looking similar controllers. i've checked entire route class , found nothing.

if layout blade template, create view composer injects variables layout. in app/providers/appserviceprovider.php add this:

public function boot() {     app('view')->composer('layouts.master', function ($view) {         $action = app('request')->route()->getaction();          $controller = class_basename($action['controller']);          list($controller, $action) = explode('@', $controller);          $view->with(compact('controller', 'action'));     }); } 

you have 2 variables available in layout template: $controller , $action.


Popular posts from this blog