Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding ID to route #1

Closed
illuminate3 opened this issue Feb 20, 2015 · 5 comments
Closed

adding ID to route #1

illuminate3 opened this issue Feb 20, 2015 · 5 comments
Labels

Comments

@illuminate3
Copy link

hmmm, this doesn't seem possible.

->add('view profile', 'profiles'. Auth::user()->id )

Or am I doing something wrong again?

@kaidesu
Copy link
Contributor

kaidesu commented Feb 20, 2015

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.

@illuminate3
Copy link
Author

@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

@kaidesu
Copy link
Contributor

kaidesu commented Feb 21, 2015

I'll be sure to look into this!

@kaidesu kaidesu added the bug label Mar 6, 2015
@kaidesu
Copy link
Contributor

kaidesu commented Apr 16, 2015

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:

@kaidesu kaidesu closed this as completed Apr 16, 2015
@kaidesu kaidesu added question and removed bug labels Apr 16, 2015
@IndraGunawan
Copy link

What is the solution for this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants