質問編集履歴

3

追記しました

2020/12/23 14:04

投稿

kipipipi
kipipipi

スコア60

title CHANGED
File without changes
body CHANGED
@@ -58,6 +58,12 @@
58
58
  }
59
59
  ```
60
60
 
61
+ **次のようにtinkerを記入するとsql分はこのようになっています**
62
+ ```ここに言語を入力
63
+ >>> App\Models\RentalHist::find('RRRRR1')->devices()->toSql();
64
+ => "select * from `devices` inner join `device_rental` on `devices`.`device_id` = `device_rental`.`device_id` where `device_rental`.`device_id` = ?"
65
+ ```
66
+
61
67
  何かお気づきになることはありますでしょうか?
62
68
  よろしくお願いいたします。
63
69
 

2

追記しました

2020/12/23 14:04

投稿

kipipipi
kipipipi

スコア60

title CHANGED
File without changes
body CHANGED
@@ -5,14 +5,15 @@
5
5
  rental_histsテーブル
6
6
 
7
7
  というテーブルのリレーションができずはまっています。
8
+
8
- devicesテーブル
9
+ **devicesテーブル**
9
10
  ![devices](1718efb8856a9fd21acbfa1691342156.png)
10
- device_rental(中間テーブル)
11
+ **device_rental(中間テーブル)**
11
12
  ![中間テーブル](79dca96662168e890dbc0b5f489ade39.png)
12
- rental_histsテーブル
13
+ **rental_histsテーブル**
13
14
  ![rental_hists](0ced4e66d9333697a1c70825f2be25b3.jpeg)
14
15
 
15
- Device.php モデル
16
+ **Device.php モデル**
16
17
  ```ここに言語を入力
17
18
  /**
18
19
  * retnal_histsテーブルとのリレーション
@@ -22,7 +23,7 @@
22
23
  }
23
24
  ```
24
25
 
25
- RentalHist.php モデル
26
+ **RentalHist.php モデル**
26
27
  ```ここに言語を入力
27
28
  public function devices()
28
29
  {
@@ -38,7 +39,7 @@
38
39
  }
39
40
  ```
40
41
 
41
- もちろん、idで検索すれば値は取得できます
42
+ **もちろん、idで検索すれば値は取得できます**
42
43
  ```ここに言語を入力
43
44
  >>> App\Models\RentalHist::find('RRRRR1');
44
45
  => App\Models\RentalHist {#4275

1

追記しました

2020/12/23 11:49

投稿

kipipipi
kipipipi

スコア60

title CHANGED
File without changes
body CHANGED
@@ -5,8 +5,11 @@
5
5
  rental_histsテーブル
6
6
 
7
7
  というテーブルのリレーションができずはまっています。
8
+ devicesテーブル
8
9
  ![devices](1718efb8856a9fd21acbfa1691342156.png)
10
+ device_rental(中間テーブル)
9
11
  ![中間テーブル](79dca96662168e890dbc0b5f489ade39.png)
12
+ rental_histsテーブル
10
13
  ![rental_hists](0ced4e66d9333697a1c70825f2be25b3.jpeg)
11
14
 
12
15
  Device.php モデル