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 關注
- 125 瀏覽
添加回答
舉報