A
A
Anton Shelestov2020-11-12 15:34:58
Laravel
Anton Shelestov, 2020-11-12 15:34:58

Is it possible to add an arbitrary parameter to routes?

Hello!

For example, there is a route or resource:

Route::get('users/settings/reset', '[email protected]')->name('users.settings.reset');
Route::resource('users', 'UserController');


Can I somehow add my own unique parameter to the definition of routes?
For example:
Route::get('users/settings/reset', '[email protected]')->name('users.settings.reset')->custom('Комментарий к роуту');
Route::resource('users', 'UserController')->custom([
    'index' => 'Комментарий к index роуту',
    'create' => 'Комментарий к create роуту',
]);


Or in some other form.

This is necessary so that I can generate a page in the admin panel with all admin routes and different users can be given certain accesses.

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2020-11-13
@Alex_Wells

What you want is done using annotations or a similar mechanism.
Only in this case you don't need anything like that. It is necessary to delimit the rights not by receptions, but by actions. To do this, there are policies and libraries that manage them, such as bouncer. Read and google.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question