J
J
jazzus2019-01-24 03:09:59
Laravel
jazzus, 2019-01-24 03:09:59

How to get all values ​​from middleware?

The task is to check access in a route group. In the route group, I pass 2 values ​​separated by commas.

Route::group(['middleware' => 'roleIds:'.Role::ID__ADMIN,Role::ID__MODERATOR], function () {
роуты
});

But in the CheckRole class, it
dd($roleIds);
returns the first value in the list.
How can you access the second value? Yes, and in principle to all values. How it is better to implement it?
UPDATE
As a result, I tried many options - several values ​​​​are not transferred. At the moment, I decided that I am passing the value to the middelvar 1 - a constant of arrays (groups) of roles defined in the CheckRole class, respectively, the desired group is already selected through the if and the check is in progress. I don’t translate into solutions. not a solution

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2019-01-24
@alexey-m-ukolov

Collect the string correctly.
Better like this:

'roleIds:' . implode(',', [Role::ID__ADMIN, Role::ID__MODERATOR])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question