I'm wanting to only show links if the logged in user has a "1" on the admin column from the users table.
What I've tried:
In my User.php
public function isAdmin(){
if(Auth::User()->administrator == 1){
return true;
}else{
return false;
};
}
My migration:
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('firstname');
$table->string('lastname');
$table->boolean('administrator')->default(0);
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
My Blade:
@if(Auth::check())
@if ()
<a href="/admin">some link for admins only</a>
@endif
@endif
The link doesn't show up no matter who logs in.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire