我正在尝试分别查看每个用户的详细信息

时间:2019-11-13 12:01:12

标签: laravel laravel-5 eloquent laravel-6

我有一个tutors列表,其中有一个相应的timeslotday,我将实例tutors::all()tutor_availabilities::all()从控制器传递给了{ {1}},当我想查看index的详细信息及其可用性tutortimeslot时,它显示了所有导师的可用性daytimeslot

Tutor_availability模型

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 基本上只查看最新导师的详细信息

0 个答案:

没有答案