I have two tables ..
User and UserMeta
I made relationship between them with hasOne().
Model
public function user_meta() {
return $this->hasOne('App\UserMeta');
}
Controller
public function index() {
$users = User::orderBy('id', 'desc')->paginate(10);
return view('users.index')->with('users', $users);
}
View
@forelse ($users as $user)
@empty
@endforelse
This return error
Trying to get property 'country' of non-object
But here if I use dd() like this.
@forelse ($users as $user)
@empty
@endforelse
I can see the value return correctly. United State
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2kaMcTR
via IFTTT
Aucun commentaire:
Enregistrer un commentaire