質問編集履歴
1
モデル情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -85,3 +85,229 @@
|
|
85
85
|
もろもろすっとばしていますが・・・(;´∀`)
|
86
86
|
|
87
87
|
よろしくお願いします。
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
下記、モデル情報です。
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
#### stores
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
<?php
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
namespace App\Models;
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
use Illuminate\Database\Eloquent\Model;
|
110
|
+
|
111
|
+
use Illuminate\Database\Eloquent\SoftDeletes;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
class Stores extends Model
|
116
|
+
|
117
|
+
{
|
118
|
+
|
119
|
+
use SoftDeletes;
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
/**
|
124
|
+
|
125
|
+
* モデルと関連しているテーブル
|
126
|
+
|
127
|
+
*
|
128
|
+
|
129
|
+
* @var string
|
130
|
+
|
131
|
+
*/
|
132
|
+
|
133
|
+
protected $table = 'stores';
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
/**
|
138
|
+
|
139
|
+
* 日付のデータ型でFormatを利用するカラムを指定
|
140
|
+
|
141
|
+
*/
|
142
|
+
|
143
|
+
protected $dates = [
|
144
|
+
|
145
|
+
'created_at',
|
146
|
+
|
147
|
+
'updated_at',
|
148
|
+
|
149
|
+
'deleted_at'
|
150
|
+
|
151
|
+
];
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
/**
|
156
|
+
|
157
|
+
* コース情報とのリレーション
|
158
|
+
|
159
|
+
* @return type
|
160
|
+
|
161
|
+
*/
|
162
|
+
|
163
|
+
public function storeCourses()
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
return $this->belongsToMany(StoreCourses::class, 'courses_stores', 'store_id', 'course_id');
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
#### courses_stores
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
<?php
|
184
|
+
|
185
|
+
namespace App\Models;
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
use Illuminate\Database\Eloquent\Model;
|
190
|
+
|
191
|
+
use Illuminate\Database\Eloquent\SoftDeletes;
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
class CoursesStores extends Model
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
use SoftDeletes;
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
/**
|
204
|
+
|
205
|
+
* モデルと関連しているテーブル
|
206
|
+
|
207
|
+
*
|
208
|
+
|
209
|
+
* @var string
|
210
|
+
|
211
|
+
*/
|
212
|
+
|
213
|
+
protected $table = 'courses_stores';
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
/**
|
218
|
+
|
219
|
+
* 日付のデータ型でFormatを利用するカラムを指定
|
220
|
+
|
221
|
+
*/
|
222
|
+
|
223
|
+
protected $dates = [
|
224
|
+
|
225
|
+
'created_at',
|
226
|
+
|
227
|
+
'updated_at',
|
228
|
+
|
229
|
+
'deleted_at'
|
230
|
+
|
231
|
+
];
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
```
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
#### courses
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
```
|
244
|
+
|
245
|
+
<?php
|
246
|
+
|
247
|
+
namespace App\Models;
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
use Illuminate\Database\Eloquent\Model;
|
252
|
+
|
253
|
+
use Illuminate\Database\Eloquent\SoftDeletes;
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
class Courses extends Model
|
258
|
+
|
259
|
+
{
|
260
|
+
|
261
|
+
use SoftDeletes;
|
262
|
+
|
263
|
+
/**
|
264
|
+
|
265
|
+
* モデルと関連しているテーブル
|
266
|
+
|
267
|
+
*
|
268
|
+
|
269
|
+
* @var string
|
270
|
+
|
271
|
+
*/
|
272
|
+
|
273
|
+
protected $table = 'courses';
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
/**
|
278
|
+
|
279
|
+
* 日付のデータ型でFormatを利用するカラムを指定
|
280
|
+
|
281
|
+
*/
|
282
|
+
|
283
|
+
protected $dates = [
|
284
|
+
|
285
|
+
'created_at',
|
286
|
+
|
287
|
+
'updated_at',
|
288
|
+
|
289
|
+
'deleted_at'
|
290
|
+
|
291
|
+
];
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
/**
|
296
|
+
|
297
|
+
* 店舗情報とのリレーション
|
298
|
+
|
299
|
+
* @return type
|
300
|
+
|
301
|
+
*/
|
302
|
+
|
303
|
+
public function stores()
|
304
|
+
|
305
|
+
{
|
306
|
+
|
307
|
+
return $this->belongsToMany(Stores::class, 'courses_stores', 'course_id', 'store_id');
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
```
|