1 回答

TA貢獻1712條經驗 獲得超3個贊
您需要像這樣為公司與用戶建立關系
公司模式
public function user()
{
return $this->belongsTo(Company::class,'user_id');
}
你的查詢將變成
response['appointMent'] = $this->appointment->where('user_id', Auth::guard('user')->user()->id)
->whereIn('status', array('Sched', 'Going', 'Request Appointment'))
->whereDate('set_date', '>', Carbon::now()->subDays(1))
->with(['company.user','applicant','job'])->get();
現在用戶關系將在公司內部
或者反過來將是用戶模型
public function company()
{
return $this->hasOne(User::class); //Or hasMany depends on your needs
}
然后下面的查詢將更改為
response['appointMent'] = $this->appointment->where('user_id', Auth::guard('user')->user()->id)
->whereIn('status', array('Sched', 'Going', 'Request Appointment'))
->whereDate('set_date', '>', Carbon::now()->subDays(1))
->with(['user.company','applicant','job'])->get();
- 1 回答
- 0 關注
- 209 瀏覽
添加回答
舉報