F
Filament2mo ago
arif

How to Display Related Model Data on the Edit Page?

I have two models: User and DetailUser. I want to display the name from DetailUser on the edit page. However, I'm unable to display it using
detailUser.name
detailUser.name
. Why is this happening? Model User.php
public function userDetail()
{
return $this->hasOne(UserDetail::class, 'user_id', 'id');
}
public function userDetail()
{
return $this->hasOne(UserDetail::class, 'user_id', 'id');
}
Model UserDetail.php
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
2 Replies
arif
arif2mo ago
up
yebor974
yebor9742mo ago
Hi, your relation is userDetail not detailUser as you wrote with detailUser.name
Want results from more Discord servers?
Add your server