0

I am trying to get the current controller name in my base controller in Laravel 3.2 but it returns null. Within my Home Controller there's no problem.

How can I get this value within my Base_Controller?

<?php

class Base_Controller extends Controller {

    public $page_data = array();


    public function __call($method, $parameters) {
        return Response::error('404');
    }


    public function __construct() {


        $this->page_data['body_id'] = Request::$route->controller;


        parent::__construct();
    }

}
Laurence
  • 58,936
  • 21
  • 171
  • 212

1 Answers1

1

Why don't you use the get_called_class() if you have PHP 5.3 available so that you can get the controllers class name? It is a workaround though and not exactly what you were looking for...

Panais
  • 361
  • 3
  • 14
  • Awesome thanks! is theres anyway to have the controller action too? – i52poutine Feb 10 '13 at 08:52
  • Sure, check this: [http://stackoverflow.com/questions/2115913/retrieving-the-name-of-the-current-function-in-php](http://stackoverflow.com/questions/2115913/retrieving-the-name-of-the-current-function-in-php) – Panais Feb 10 '13 at 08:56