交互式爱情
您需要像这样为公司与用户建立关系公司模式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();