V
V
Voll.2016-05-26 17:12:37
Laravel
Voll., 2016-05-26 17:12:37

How to intercept prefix and make it available globally by controller in Laravel?

Organized so Routing

Route::group( array('prefix'=> '{lang}'), function(){
   Route::get('/cms/users/', 'cms\[email protected]');
});

Now I want to somehow intercept globally for the controller, I think that I need to dig aside
protected $lang;

    public function __construct($lang)
    {
        $this->lang = $lang;
    }

But unfortunately it doesn't start like that, only for each function separately:
public function index($lang)
How to make $lang - prefix, be a constant variable in the entire controller for all functions? There is a solution? I will be grateful!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-05-26
@vollthegreat

I don't remember 100% but somehow
\Route::getCurrentRoute()->parameter('lang')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question