回答編集履歴
1
リレーションの命名規則に従い修正。
answer
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
$base_list = Base::with(['ref'])->all();
|
4
4
|
foreach($base_list as $index => $base) {
|
5
5
|
if($base->ref_type == 'Hoge') {
|
6
|
-
$base->
|
6
|
+
$base->images;
|
7
7
|
}
|
8
8
|
}
|
9
9
|
// [
|
10
|
-
// ['id' => 1, 'ref_id' => 1, 'ref_type' => 'Hoge', 'ref' => [id => 1, 'name' => 'hoge', 'number' => 0, '
|
10
|
+
// ['id' => 1, 'ref_id' => 1, 'ref_type' => 'Hoge', 'ref' => [id => 1, 'name' => 'hoge', 'number' => 0, 'images' => [['id' => 1, 'hoge_id' => 1, 'path' => 'image.jpg']]]],
|
11
11
|
// ['id' => 2, 'ref_id' => 1, 'ref_type' => 'Fuga', 'ref' => [id => 1, 'name' => 'fuga', 'text' => 'a']],
|
12
12
|
// ]
|
13
13
|
```
|