回答編集履歴
1
追記
answer
CHANGED
@@ -6,4 +6,23 @@
|
|
6
6
|
|
7
7
|
`Address::where('user_id', 1)` で返す値は、Addressモデルではなく、`Builder`なので、
|
8
8
|
|
9
|
-
`->first()` をつけて、`Address`を返さなくてはいけません。
|
9
|
+
`->first()` をつけて、`Address`を返さなくてはいけません。
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
```php
|
14
|
+
<?php
|
15
|
+
|
16
|
+
namespace App;
|
17
|
+
|
18
|
+
use Illuminate\Database\Eloquent\Model;
|
19
|
+
|
20
|
+
class Address extends Model
|
21
|
+
{
|
22
|
+
// ここの定義方法も間違っている
|
23
|
+
protected $fillable = [
|
24
|
+
'name'
|
25
|
+
];
|
26
|
+
|
27
|
+
}
|
28
|
+
```
|