I created an artisan custom command and in the handle() method i need to get a few info about users.
When i run:
handle() {
$users = User::all();
foreach($users as $user) {
$this->line($user->name);
}
}
it works, but i need something like:
handle() {
$users = User::all();
foreach($users as $user) {
$this->line($user->phone->number);
}
}
And i get Trying to get property of non-object.
If i run the same code above in a controller it works just fine.
Does anyone have an idea?
via Felipe Martins