如何在Laravel中阻止访问具有3类用户的另一个页面

i have problem with laravel cus im begginer but i work with php languge very well and my Question:

I created a table for users in my database and create column for type There are 3 user types in my table: customers - Workers - Factories

How can i use middlewarre or anything else Prevent access to other pages

public function Signupuser(Request $request){
    $email=$request['email'];
    $username=$request['username'];
    $tell=$request['mobilenumber'];
    $pass=bcrypt($request['password']);
    $status_reg=$request['status_register'];

   $usertable=new UserTable();
   $usertable->username=$username;
   $usertable->email=$email;
   $usertable->Password=$pass;
   $usertable->Tell=$tell;
   $usertable->StatusReg=$status_reg;
   $usertable->save();
   Auth::login($usertable);
   if($status_reg=='factory'){
       return redirect()->route('FactoryDashboard');
   }
    if($status_reg=='worker'){
        return redirect()->route('WorkerDashboard');
    }
    if($status_reg=='customer'){
        return redirect()->route('CustomerDashboard');
    }

}

public function signinuser(Request $request){
    $email=$request['email'];
    $pass=$request['pass'];
    if (Auth::attempt(['email'=>$email,'password'=>$pass])){
        $status = Auth::user()->StatusReg;

        return $status;

    }
    else{
        return "nokey";
    }

}

i used with one middleware but this middleware dosent work

<?php
  namespace App\Http\Middleware;
  use App\UserTable;
   use Closure;

  class WorkerMiddleware
  {
/**
 * Handle an incoming request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
 */
public function handle($request, Closure $next)
{
    if($request->user() && $request->user()->StatusReg !='worker'){
        return redirect('homepage');
    }
    return $next($request);
}
}

please help guys

Your scenario is usually dealt with by using the Authorization service of Laravel.

For example, you could add the following to your app\Providers\AuthServiceProvider.php file:

Gate::define('factory', function ($user) {
    return $user->StatusReg == 'factory';
});

Gate::define('worker', function ($user) {
    return $user->StatusReg == 'worker';
});

Gate::define('customer', function ($user) {
    return $user->StatusReg == 'customer';
});

And then you can use it in your application like the following:

if (Gate::allows('worker')) {
    //...
}

if (Gate::denies('customer')) {
    //...
}    

There are plenty more usage examples in the docs:

https://laravel.com/docs/5.6/authorization