Comments (5)
@lavary , @cgrice , @uyab , @afraca , @DMeganoski , Can you please help me to short out this issue?
from laravel-menu.
I'm sorry @mtkumar82 , it's been 3 years since I last used this and do not have the means to help you with this.
One piece of advice I can give you: instead of saying "it's not working" be more precise. What is the expected behaviour and what is it that you see?
from laravel-menu.
Hello @afraca ,
Thanks for your quick message, Actually when I am using filter function there , and trying to add some echo statement there with die, Its not doing anything there. I actually want to show menus, based on user role and permissions. For user role and permissions I am using spatie/laravel-permission extension,
Please let me know if you understand my problem?
Thanks
from laravel-menu.
@mtkumar82 Issues is not really the place to ask this, you'd be better on stack overflow or a forum for laravel like laracasts. Github issues is more to report a bug in the repository, this is a bug in your app.
But I will throw you a bone and tell you what your problem likely is. Your filter function is using User::get()->can()
(which I would expect would throw an error as get should return an instance of the Builder class) when it should be auth()->user()->can()
from laravel-menu.
Hello @DMeganoski , Thanks for your reply, But I short out that issue, I need to put that filter function in end of menus collections like below.
$navbar->filter(function($navbar) {
$userId =Auth::guard('admin')->user()->id;
$user = User::find($userId);
$userRole = $user->role_id; // Role id 1 is for admin user
if($user->can( $navbar->data('permission')) || $userRole==1) {
return true;
}
return false;
});
Sharing it here, May be someone else can get help from this.
Thanks again.
from laravel-menu.
Related Issues (20)
- Defining an HTML-Attribute for the HTML A-Tag HOT 1
- components inside prepend HOT 3
- How to call link->attr target on blade? HOT 2
- Active class override HOT 1
- Active link and item classes HOT 4
- BUG active link. Forced https HOT 4
- build menu with nested categories from database HOT 1
- Sorting subitems
- Filtering items: Class "App\Http\Middleware\User" not found HOT 2
- Custom div menu layout
- Multiple Meta Data
- Submenus HOT 1
- Manage menu module wise and display on admin area all menus HOT 1
- In case you are using bootstrap 5 (currently in beta) you need to set the data-toggle-attribute option from data-toggle to data-bs-toggle in your config/laravel-menu/settings.php. HOT 1
- create menus in Laravel 9 HOT 3
- Passing null to parameter #1 ($string) of type string is deprecated .. Menu/Builder.php on line 303 (LF 10 / PHP 8.1) HOT 2
- @lm_attrs directive does not resolved
- how to make menu with icon HOT 1
- Filter on Menu not working HOT 1
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 laravel-menu.