Search code examples
phplaravelurlgetlaravel-5.3

How to get parameter in url (laravel 5.3)?


My url is like this : http://localhost/mysystem/public/users/index/2016

I want to get 2016, because I need it. But, I'm confused

Is there any people who can help me?


Solution

  • In your previous question I can see this method:

    public function store(CreateUserRequest $request)
    

    And your route should look like this (partially taken from previous answer too):

    Route::get('users/store/{year}', 'UserController@store')->name('users.store.year');
    

    Note, that if you'll build store method with Route::resource(), you'll not be able to pass year through URL.

    So, to make it work you need to set route and to change method to this:

    public function store(CreateUserRequest $request, $year)
    

    $year variable will have 2016 value.