Closed illuminate3 closed 9 years ago
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
.
@bugs figured as much, however, this package is another of yours I'm all over :smile:
@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
I'll be sure to look into this!
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:
What is the solution for this problem?
hmmm, this doesn't seem possible.
Or am I doing something wrong again?