回答編集履歴
2
hasMany 追加
test
CHANGED
@@ -21,3 +21,23 @@
|
|
21
21
|
}
|
22
22
|
|
23
23
|
```
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
```php
|
28
|
+
|
29
|
+
class Profile extends Model
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
public function posts()
|
34
|
+
|
35
|
+
{
|
36
|
+
|
37
|
+
return $this->hasMany(Post::class, 'user_id', 'user_id');
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
```
|
1
余分
test
CHANGED
@@ -21,23 +21,3 @@
|
|
21
21
|
}
|
22
22
|
|
23
23
|
```
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
```php
|
28
|
-
|
29
|
-
class Profile extends Model
|
30
|
-
|
31
|
-
{
|
32
|
-
|
33
|
-
public function profile()
|
34
|
-
|
35
|
-
{
|
36
|
-
|
37
|
-
return $this->belongsTo(Post::class, 'user_id', 'user_id');
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
}
|
42
|
-
|
43
|
-
```
|