質問編集履歴
3
codeの中に記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,16 +15,17 @@
|
|
15
15
|
Table2:user_id,user_name
|
16
16
|
|
17
17
|
Modelは
|
18
|
-
|
18
|
+
Table1-Modelは
|
19
|
+
```php
|
19
20
|
public function belong_user() {
|
20
21
|
return $this->belongsTo(Table2::class);
|
21
22
|
}
|
22
|
-
---------------------
|
23
|
-
|
23
|
+
```
|
24
|
-
-
|
24
|
+
で、Table2-Modelは
|
25
|
+
```php
|
25
26
|
public function has_table1() {
|
26
27
|
return $this->hasOne(Table1::class);
|
27
28
|
}
|
28
|
-
|
29
|
+
```
|
29
30
|
|
30
31
|
よろしくお願いします。
|
2
テーブル構成追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,6 +10,10 @@
|
|
10
10
|
return $users;
|
11
11
|
```
|
12
12
|
|
13
|
+
データベース構成は以下の通りです。
|
14
|
+
Table1:user_id,tokuten
|
15
|
+
Table2:user_id,user_name
|
16
|
+
|
13
17
|
Modelは
|
14
18
|
-----Table1-Model------
|
15
19
|
public function belong_user() {
|
1
説明追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,4 +10,17 @@
|
|
10
10
|
return $users;
|
11
11
|
```
|
12
12
|
|
13
|
+
Modelは
|
14
|
+
-----Table1-Model------
|
15
|
+
public function belong_user() {
|
16
|
+
return $this->belongsTo(Table2::class);
|
17
|
+
}
|
18
|
+
---------------------
|
19
|
+
で
|
20
|
+
-----Tables2-Model------
|
21
|
+
public function has_table1() {
|
22
|
+
return $this->hasOne(Table1::class);
|
23
|
+
}
|
24
|
+
---------------------
|
25
|
+
|
13
26
|
よろしくお願いします。
|