Code Monkey home page Code Monkey logo

Comments (5)

kaidesu avatar kaidesu commented on August 22, 2024

There's a few quirks I'm working out, so I wouldn't be surprised if its a legit bug right now.

Also, looks like you need a trailing slash after profiles?

use Auth;
use Menu;

...

Menu::make('example', function($menu)) {
    $menu->add('View Profile', 'profiles/'.Auth::user()->id);
});

And be sure to check if you're logged in first, otherwise Auth::user() will return null.

from menus.

illuminate3 avatar illuminate3 commented on August 22, 2024

@bugs
figured as much, however, this package is another of yours I'm all over 😄

@error
I have the Auth::user()->id displaying on the same page, so not a null situation.

<?php namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use Auth;
use Menu;

class MenuServiceProvider extends ServiceProvider {

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Menu::make('public', function($menu) {
            $menu->add('Rakko', 'welcome');
            $menu->add('Profiles', 'profiles');
//          $menu->add('View Profile', 'profiles/'.Auth::user()->id);
//          $menu->add('view profile', 'profiles'. Auth::user()->id );
        });
    }

I don't have a register method.

Error:

Trying to get property of non-object

from menus.

kaidesu avatar kaidesu commented on August 22, 2024

I'll be sure to look into this!

from menus.

kaidesu avatar kaidesu commented on August 22, 2024

I believe this is simply due to the loading order of service providers. If you die and dump the result of Auth::user() you'll find that it is null (thus, the Trying to get property of non-object error). The session data is not loaded until after all service providers have booted.

See the following forum threads for more information:

from menus.

IndraGunawan avatar IndraGunawan commented on August 22, 2024

What is the solution for this problem?

from menus.

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.