jeudi 30 mai 2019

How to filter in laravel using middleware?

I am trying to finer all active courses and here is what I've tried.

Middleware is called Status

public function handle($request, Closure $next)
    {
      $status = $request->status();
      if($status == 'active'){
        return view('admin.courses.index');
      }

        return $next($request);
    }

My route calls the middleware

Route::get('admin/courses/?active', 'Admin\CoursesController@index')->middleware('status');

My view has a button that calls the route

<a href="" style="margin-left:10px;" class="btn btn-success">
            Active <span class="badge badge-light"></span>
          <span class="sr-only">total courses</span></a>

This code is not filtering the records and I'm not sure what I'm doing wrong.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire