我有一个tutors
列表,其中有一个相应的timeslot
和day
,我将实例tutors::all()
和tutor_availabilities::all()
从控制器传递给了{ {1}},当我想查看index
的详细信息及其可用性tutor
和timeslot
时,它显示了所有导师的可用性day
和timeslot
。
day
class Tutor_availability extends Model
{
protected $guarded = ['id', '_token'];
public function day()
{
return $this->belongsTo('App\Day', 'day_id');
}
public function timeslot()
{
return $this->belongsTo('App\Timeslot');
}
public function tutor()
{
return $this->hasOne('App\Tutor');
}
}
public function index()
{
$tutors = Tutor::latest()->paginate(5);
$tutor_availabilities = Tutor_availability::all();
return view('tutors.index', [
'tutors' => $tutors,
'tutor_availabilities' => $tutor_availabilities
]);
}
这是我得到的输出: https://i.imgur.com/heoyWpZ.png 基本上只查看最新导师的详细信息