letrunghieu / active

The helper class for Laravel applications to get active class base on current route
https://www.hieule.info/tag/laravel-active/
MIT License
414 stars 83 forks source link

Active 2.0 Laravel 5 action issue #10

Closed mattrandallbecker closed 9 years ago

mattrandallbecker commented 9 years ago

I'm not sure if this is new for Laravel 5 or what, but specifically with this code

Active.php

public function action($actions, $class = 'active')

$routeAction = $this->_router->currentRouteAction();

$this->_router->currentRouteAction() returns the full path of the action

i.e. (App\Http\Controllers\MyController@index rather than MyController@index)

So when using Active::action('MyController@index') it will fail when following the documentation.

mattrandallbecker commented 9 years ago

Replacing

$routeAction = $this->_router->currentRouteAction();

with

$routeExploded = explode('\',$this->_router->currentRouteAction()); $routeAction = end($routeExploded );

seems to make the functions behavior match the documentation

mattrandallbecker commented 9 years ago

I just created a pull request instead of leaving the issue open.