Laravel 5.1でブレードを使用してネストされた配列を表示しようとしましたが、これを行うことはできません:
コントローラ:
public function track($id){
$tracks = track::with('trials.samples')->where('trials_id',$id)->get();
//return $tracks;
return view('Tracks.index',compact('tracks'));
}
Traks.index:
{{ $track['samples']['variety'] }}
$tracks を返す
[{
"id": 1,
"trials_id": 1,
"date": "2015-12-16",
"comments": "\u0646\u062a\u06cc\u062c\u0647 \u062e\u0627\u0635\u06cc \u0646\u062f\u0627\u0634\u062a\u0647 !",
"created_at": "-0001-11-30 00:00:00",
"updated_at": "-0001-11-30 00:00:00",
"trials": {
"id": 1,
"persons_id": 1,
"samples_id": 1,
"amount": "125000",
"date": "2015-12-09",
"comments": "",
"code": "5CEPY",
"created_at": "2015-12-08 06:46:58",
"updated_at": "2015-12-08 06:46:58",
"samples": {
"id": 1,
"variety": "keyhan",
"supplier_id": 1,
"lot_number": "2550",
"date": "2015-12-11",
"amount": 125000,
"unit_id": 1,
"technical_fact": "\u0641\u0646\u06cc",
"comments": "1",
"file_address": "",
"category_id": 1,
"created_at": "2015-12-08 06:46:34",
"updated_at": "2015-12-08 06:46:34"
}
}
}]
私もこのコードを試しましたが、何も表示されません:
{{ $track['trials.samples']['variety'] }}
{{ $track->samples['variety'] }}