Giter VIP home page Giter VIP logo

Comments (5)

mtkumar82 avatar mtkumar82 commented on July 17, 2024

@lavary , @cgrice , @uyab , @afraca , @DMeganoski , Can you please help me to short out this issue?

from laravel-menu.

afraca avatar afraca commented on July 17, 2024

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.

mtkumar82 avatar mtkumar82 commented on July 17, 2024

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.

DMeganoski avatar DMeganoski commented on July 17, 2024

@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.

mtkumar82 avatar mtkumar82 commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.