Answer the question
In order to leave comments, you need to log in
How to exclude a specific group of users from a form?
There is a category of users "amateur photographer". There is a directory in which there are a lot of other categories, in the filter it is possible to select a category, and so I want to remove the user category "amateur" from the filter
1. In the filter form, categories are displayed like this
{!! Form::select('category_id', $categories->lists('name', 'slug')->prepend('..', ''), $category ? $category->slug : null, ['id' => 'category_id', 'class' => 'form-control js-change-fields']) !!}
Answer the question
In order to leave comments, you need to log in
1 - The question is not clear. You can remove a category from the database, you can filter at the level of a database query, remove it from a collection or an array. See what you need.
Points 2 and 3 - authorization. The doc is well described.
$categories->filter(function ($category) {
return $category->name != "фотолюбитель";
});
For the first question, you have already been offered many options.
The second and third issue is solved by registering users.
Create a table user , role and role_user . The latter has a many-to-many relationship. One user in theory can have multiple roles. Describe a hasRole($role) method that will return true if the user has a $role group and false otherwise. And with that, you can close access to anything and anyone.
Yan-s , In general, the first question was solved
3rd question solved:
@if(Auth::user()->category_id == 17)
не видно меню
@else
всем остальным видно
@endif
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question