質問編集履歴

2

Modelの追記をしました

2020/08/31 10:10

投稿

chocomint20
chocomint20

スコア1

test CHANGED
File without changes
test CHANGED
@@ -181,3 +181,227 @@
181
181
 
182
182
 
183
183
  ```
184
+
185
+
186
+
187
+ ### Product.php
188
+
189
+
190
+
191
+ ```
192
+
193
+ <?php
194
+
195
+
196
+
197
+ namespace App;
198
+
199
+
200
+
201
+ use Illuminate\Database\Eloquent\Model;
202
+
203
+
204
+
205
+ class Product extends Model
206
+
207
+ {
208
+
209
+ protected $fillable = [
210
+
211
+ 'pic','title', 'overview', 'category_id', 'contents', 'price', 'user_id', 'delete_flg',
212
+
213
+ ];
214
+
215
+
216
+
217
+ public function category()
218
+
219
+ {
220
+
221
+ return $this->belongsTo('App\Category');
222
+
223
+ }
224
+
225
+
226
+
227
+ public function reviews()
228
+
229
+ {
230
+
231
+ return $this->hasMany('App\Review');
232
+
233
+ }
234
+
235
+
236
+
237
+ public function user()
238
+
239
+ {
240
+
241
+ return $this->belongsTo('App\User');
242
+
243
+ }
244
+
245
+ }
246
+
247
+
248
+
249
+ ```
250
+
251
+
252
+
253
+ ### Review.php
254
+
255
+
256
+
257
+ ```
258
+
259
+ <?php
260
+
261
+
262
+
263
+ namespace App;
264
+
265
+
266
+
267
+ use Illuminate\Database\Eloquent\Model;
268
+
269
+
270
+
271
+ class Review extends Model
272
+
273
+ {
274
+
275
+ public function product()
276
+
277
+ {
278
+
279
+ return $this->belongsTo('App\Product');
280
+
281
+ }
282
+
283
+
284
+
285
+ public function user()
286
+
287
+ {
288
+
289
+ return $this->belongsTo('App\User');
290
+
291
+ }
292
+
293
+ }
294
+
295
+
296
+
297
+ ```
298
+
299
+
300
+
301
+ ### User.php
302
+
303
+
304
+
305
+ ```
306
+
307
+ <?php
308
+
309
+
310
+
311
+ namespace App;
312
+
313
+
314
+
315
+ use Illuminate\Notifications\Notifiable;
316
+
317
+ use Illuminate\Contracts\Auth\MustVerifyEmail;
318
+
319
+ use Illuminate\Foundation\Auth\User as Authenticatable;
320
+
321
+
322
+
323
+ class User extends Authenticatable
324
+
325
+ {
326
+
327
+ use Notifiable;
328
+
329
+
330
+
331
+ /**
332
+
333
+ * The attributes that are mass assignable.
334
+
335
+ *
336
+
337
+ * @var array
338
+
339
+ */
340
+
341
+ protected $fillable = [
342
+
343
+ 'pic', 'name', 'introduction', 'email', 'password', 'delete_flg',
344
+
345
+ ];
346
+
347
+
348
+
349
+ /**
350
+
351
+ * The attributes that should be hidden for arrays.
352
+
353
+ *
354
+
355
+ * @var array
356
+
357
+ */
358
+
359
+ protected $hidden = [
360
+
361
+ 'password', 'remember_token',
362
+
363
+ ];
364
+
365
+
366
+
367
+ /**
368
+
369
+ * The attributes that should be cast to native types.
370
+
371
+ *
372
+
373
+ * @var array
374
+
375
+ */
376
+
377
+ protected $casts = [
378
+
379
+ 'email_verified_at' => 'datetime',
380
+
381
+ ];
382
+
383
+
384
+
385
+ public function reviews()
386
+
387
+ {
388
+
389
+ return $this->hasMany('App\Review');
390
+
391
+ }
392
+
393
+
394
+
395
+ public function products()
396
+
397
+ {
398
+
399
+ return $this->hasMany('App\Product');
400
+
401
+ }
402
+
403
+ }
404
+
405
+
406
+
407
+ ```

1

2020/08/31 10:10

投稿

chocomint20
chocomint20

スコア1

test CHANGED
@@ -1 +1 @@
1
- LaravelからVue側に渡したDBの情報評価点の平均値を表示たい
1
+ LaravelからVue側に渡したDBのレコードの平均値を表示たい
test CHANGED
@@ -1,4 +1,4 @@
1
- ### LaravelからVue側に渡したDBの情報評価点の平均値を表示したい
1
+ ### LaravelからVue側に渡したDBのレコードの平均値を表示したい
2
2
 
3
3
 
4
4