回答編集履歴
2
hasMany 追加
answer
CHANGED
@@ -9,4 +9,14 @@
|
|
9
9
|
return $this->belongsTo(Profile::class, 'user_id', 'user_id');
|
10
10
|
}
|
11
11
|
}
|
12
|
+
```
|
13
|
+
|
14
|
+
```php
|
15
|
+
class Profile extends Model
|
16
|
+
{
|
17
|
+
public function posts()
|
18
|
+
{
|
19
|
+
return $this->hasMany(Post::class, 'user_id', 'user_id');
|
20
|
+
}
|
21
|
+
}
|
12
22
|
```
|
1
余分
answer
CHANGED
@@ -9,14 +9,4 @@
|
|
9
9
|
return $this->belongsTo(Profile::class, 'user_id', 'user_id');
|
10
10
|
}
|
11
11
|
}
|
12
|
-
```
|
13
|
-
|
14
|
-
```php
|
15
|
-
class Profile extends Model
|
16
|
-
{
|
17
|
-
public function profile()
|
18
|
-
{
|
19
|
-
return $this->belongsTo(Post::class, 'user_id', 'user_id');
|
20
|
-
}
|
21
|
-
}
|
22
12
|
```
|