Answer the question
In order to leave comments, you need to log in
What is the best way to implement such a restriction?
I have user rights admin and user.
There is a link to the article editor, with the help of php I would make a stupid condition for checking if the line in the database matches the line admin, is there something ready in laravel, I just read about guard (or is it access to the page) I didn’t really understand anything
Answer the question
In order to leave comments, you need to log in
You need policies for the article model to make a policy to prescribe access and restrict using can in templates. In docks detailed examples for different situations. Or just make a check from the user. As I understand it, you have no roles and you just made the admin field in users. Then in the User model do a type check
public function isAdmin()
{
return $this->admin === 1;
}
@if (Auth::user()->isAdmin())
показать кнопку
@endif
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question