如何使用 Session(拉拉维尔)绑定表中列的详细信息



我有一个表格,可以从数据库中获取注册课程的各种学生的数据。现在在此表中,我想将"详细信息"按钮列绑定到特定学生,以便它从该特定学生的数据库中获取特定详细信息

定义Student模型。然后定义您的Details模型。一个学生有很多细节,因此在Student模型中创建一个details关系。

之后,您可以将$with属性设置为预先加载关系。将$visible属性设置为包含details将使detailsStudent转换为数组时可见。

class Student extends Model 
{
$with = ['details'];
$visible = ['id','name','details'];
function details () 
{
return $this->hasMany(Details::class);
}
}

最新更新