Level 1
Hi, try write this:
Customer::with('user')->with('student')->find(2);
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This is my Customer model
class Customer extends Model
{
use SoftDeletes;
protected $fillable = ['name','place','address','provider','userid','senderid','pin','route','voicekey','burl','amc','amc_date','voice','active'];
protected $dates = ['deleted_at','created_at','updated_at','amc_date'];
public function User()
{
return $this->hasMany('SmSPortal\User');
}
public function Student()
{
return $this->hasManyThrough('SmSPortal\Student','SmSPortal\User');
}
}
Here i want to return results with students of trashed users.
iam tried follwing
Customer::find(2)->User()->Student()->get();
i tried this in model
public function Student()
{
return $this->hasManyThrough('SmSPortal\Student','SmSPortal\User')->withTrashed();
}
but its not working pls help me
Please or to participate in this conversation.