Comments (2)
@haithamrdina Could you please try this?
<?php
namespace App\Filter;
use Illuminate\Support\Facades\Auth;
use TakiElias\Tablar\Menu\Filters\FilterInterface;
class RolePermissionMenuFilter implements FilterInterface
{
public function transform($item)
{
return $this->isVisible($item) ? $item['header'] ?? $item : false;
}
protected function isVisible($item)
{
$user = Auth::user();
if (isset($item['hasAnyRole']) && !$user->hasRole($item['hasAnyRole'], null, true)) {
return false;
}
if (isset($item['hasRole']) && !$user->hasRole($item['hasRole'])) {
return false;
}
if (isset($item['hasAnyPermission']) && !$user->isAbleTo($item['hasAnyPermission'])) {
return false;
}
return true;
}
}
from tablar.
thank you so much @takielias
from tablar.
Related Issues (15)
- Error when installing the preset HOT 1
- InvalidArgumentException HOT 2
- Livewire HOT 1
- Deprecation Warning: Passing percentage units to the global abs() function is deprecated. HOT 1
- Integration Tablar with tenancy for laravel HOT 1
- Add an option to display a vertical sidebar.
- Select box stylized HOT 8
- Select style error HOT 1
- 2 body html tags in source code and html structure not correct HOT 4
- HTML tag TITLE twice in master.blade.php and one suggestion
- How does the menu become inactive when another is selected? HOT 1
- Attempt to read property "name" on null HOT 2
- Deprecated Event HOT 5
- Not show icons in navbar HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tablar.