【发布时间】:2020-04-21 20:45:47
【问题描述】:
我有 3 个表“用户”、“学生”和“注册”。每个表都与 hasOne 关系链接。我想从班级表中获取student_id的值。是否可以找到?其实我是新人,我不明白
//代码
<a href="{{route('gallary.view',['stud_id' =>auth()->user()->student()->registration->student_id])}}">
//错误
Undefined property: Illuminate\Database\Eloquent\Relations\HasOne::$registration
【问题讨论】:
-
我从 student 中删除了 () 。它显示一个错误。是否可以访问另一个具有关系的表字段?
标签: php laravel authentication