public function setRole(User $user, array $role)
 {
     $roleModels = Role::whereIn('level', $role)->get();
     $user->roles()->sync($roleModels->map(function ($role) {
         return $role->id;
     })->toArray());
     return $user;
 }
 public function createToken()
 {
     if (Auth::check()) {
         $token = JWTAuth::fromUser(Auth::user());
     } else {
         $anonAccount = Role::where('level', 'anon')->first()->users()->first();
         if (is_null($anonAccount)) {
             // Shouldn't happen except if the db is wiped...
             \Artisan::call('user:anon');
             $anonAccount = Role::where('level', 'anon')->first()->users()->first();
         }
         Auth::login($anonAccount);
         $token = JWTAuth::fromUser(Auth::user());
     }
     return $token;
 }