2 回答
TA贡献1828条经验 获得超13个赞
假设您在将学生传递到刀片文件后尝试打印属性,请尝试以下操作:
// An example to display the `name` field inside a table, do the same for the family field
<table>
...
@foreach($students as $student)
...
<tr>
@foreach(str_split($student->name) as $character)
<td>{{ $character }}</td>
@endforeach
</tr>
...
@endforeach
...
</table>
TA贡献1893条经验 获得超10个赞
您可以定义mutator来拆分字符:
protected $appends = ['name', 'family'];
public function getNameAttribute($value)
{
return str_split($value);
}
public function getFamilyAttribute($value)
{
return str_split($value);
}
但是,您需要使用 Eloquent-builder 而不是 query-builder:
Student::select('*')->get();
- 2 回答
- 0 关注
- 101 浏览
添加回答
举报