So, I have users table which is default by laravel. But I add a new column named 'status'.
So the columns on the users table are id, name, email, password, remember_token, created_at, updated_at, status
The status values are between 0 and 1. 1 for admin, and 0 for regular user.
Also I have auth, but the problem is how can I check if users' status is 0 or 1 when login so that I can redirect it according to their status? -- admin will go to admin panel and user will go to home
User default by laravel with addition 'status'
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $fillable = [
'name', 'email', 'password', 'status',
];
protected $hidden = [
'password', 'remember_token',
];
}
HomeController also default by laravel
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
return view('home');
}
}
LoginController also default by laravel
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
THANKS.