Laravel Nova Filter Viewable By Admins Only
Hi All,
I was wonder if there was a method to show certain Filters based on User roles?
Example, suppose I have a is_admin flag on my User table.
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('password');
$table->boolean('is_admin')->default(0);
});
Schema::create('posts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('category');
});
How do I have a Nova Filter for categories viewable for admins only?
Any help would be appreciated.
if any one is passing by here wondering how to do this, here is how:
if ($request->user()->isAdmin()) {
return [
new ByCompany,
new DateFromFilter,
new DateToFilter,
];
}
return [
new ByCategory,
];
Please or to participate in this conversation.