Laravel middlware array
<p>I'm using Laravel. </p>

<p>I want to pass an array to my middleware in my api so I can check that a user has a certain role. This is my idea:</p>

<pre><code> public function handle($request, Closure $next,$role)
    {
        $employee = Employee::find($request-&gt;parameters[0]['userid']);

        foreach($role as $r) {
            if (!$employee-&gt;hasRole($employee, $r)) {
                return response()-&gt;json([
                    'result' =&gt; [
                        'message' =&gt; 'Error creating Employee'
                    ]
                ], 500);
            }
        }
        return $next($request);
    }
</code></pre>

<p>But how can I pass an to my middleware. Right now I'm doing this:</p>

<pre><code>Route::group(['middleware' =&gt; 'role:Administrator,intern'], function () {

});
</code></pre>