質問編集履歴

6

descの削除

2020/07/15 00:30

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -412,90 +412,6 @@
412
412
 
413
413
 
414
414
 
415
- ```テーブル定義
416
-
417
- MariaDB [(none)]> use laboratory
418
-
419
- Database changed
420
-
421
- MariaDB [laboratory]> show tables;
422
-
423
- +----------------------+
424
-
425
- | Tables_in_laboratory |
426
-
427
- +----------------------+
428
-
429
- | failed_jobs |
430
-
431
- | lab_evaluation |
432
-
433
- | laboratories |
434
-
435
- | migrations |
436
-
437
- | password_resets |
438
-
439
- | users |
440
-
441
- +----------------------+
442
-
443
- 6 rows in set (0.001 sec)
444
-
445
-
446
-
447
- MariaDB [laboratory]> desc laboratories
448
-
449
- -> ;
450
-
451
- +----------------+---------------------+------+-----+---------+----------------+
452
-
453
- | Field | Type | Null | Key | Default | Extra |
454
-
455
- +----------------+---------------------+------+-----+---------+----------------+
456
-
457
- | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
458
-
459
- | lab_name | varchar(191) | NO | | NULL | |
460
-
461
- | lab_univ | varchar(191) | NO | | NULL | |
462
-
463
- | lab_evaluation | double(2,1) | NO | | NULL | |
464
-
465
- | add_time | date | NO | | NULL | |
466
-
467
- | created_at | timestamp | YES | | NULL | |
468
-
469
- | updated_at | timestamp | YES | | NULL | |
470
-
471
- +----------------+---------------------+------+-----+---------+----------------+
472
-
473
- 7 rows in set (0.061 sec)
474
-
475
-
476
-
477
- MariaDB [laboratory]> desc lab_evaluation;
478
-
479
- +------------+---------------------+------+-----+---------+----------------+
480
-
481
- | Field | Type | Null | Key | Default | Extra |
482
-
483
- +------------+---------------------+------+-----+---------+----------------+
484
-
485
- | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
486
-
487
- | created_at | timestamp | YES | | NULL | |
488
-
489
- | updated_at | timestamp | YES | | NULL | |
490
-
491
- +------------+---------------------+------+-----+---------+----------------+
492
-
493
- 3 rows in set (0.031 sec)
494
-
495
- ```
496
-
497
-
498
-
499
415
  ```CREATE文の取得結果
500
416
 
501
417
  MariaDB [laboratory]> SHOW CREATE TABLE lab_evaluation;

5

MariaDBタグを追加しました。

2020/07/15 00:30

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
File without changes

4

CREATE文を追加しました。

2020/07/14 07:57

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -410,6 +410,8 @@
410
410
 
411
411
 
412
412
 
413
+
414
+
413
415
  ```テーブル定義
414
416
 
415
417
  MariaDB [(none)]> use laboratory
@@ -491,3 +493,67 @@
491
493
  3 rows in set (0.031 sec)
492
494
 
493
495
  ```
496
+
497
+
498
+
499
+ ```CREATE文の取得結果
500
+
501
+ MariaDB [laboratory]> SHOW CREATE TABLE lab_evaluation;
502
+
503
+ +-------------------------------------------------------------------------------------------------------------------------+
504
+
505
+ | Table | Create Table |
506
+
507
+ +---------------------------------------------------------------------------------------------------------------------+
508
+
509
+ | lab_evaluation | CREATE TABLE `lab_evaluation` (
510
+
511
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
512
+
513
+ `created_at` timestamp NULL DEFAULT NULL,
514
+
515
+ `updated_at` timestamp NULL DEFAULT NULL,
516
+
517
+ PRIMARY KEY (`id`)
518
+
519
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |
520
+
521
+ +------------------------------------------------------------------------------------------------------+
522
+
523
+ 1 row in set (0.041 sec)
524
+
525
+
526
+
527
+ MariaDB [laboratory]> SHOW CREATE TABLE laboratories;
528
+
529
+ +-------+
530
+
531
+ | Table | Create Table |
532
+
533
+ +---------------------------------------------------------------------------------------------+
534
+
535
+ | laboratories | CREATE TABLE `laboratories` (
536
+
537
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
538
+
539
+ `lab_name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
540
+
541
+ `lab_univ` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
542
+
543
+ `lab_evaluation` double(2,1) NOT NULL,
544
+
545
+ `add_time` date NOT NULL,
546
+
547
+ `created_at` timestamp NULL DEFAULT NULL,
548
+
549
+ `updated_at` timestamp NULL DEFAULT NULL,
550
+
551
+ PRIMARY KEY (`id`)
552
+
553
+ ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |
554
+
555
+ +---------------------------------------------------------------------------------------------------------------------+
556
+
557
+ 1 row in set (0.004 sec)
558
+
559
+ ```

3

テーブル定義をコードに変更した

2020/07/14 07:56

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -410,4 +410,84 @@
410
410
 
411
411
 
412
412
 
413
+ ```テーブル定義
414
+
415
+ MariaDB [(none)]> use laboratory
416
+
417
+ Database changed
418
+
419
+ MariaDB [laboratory]> show tables;
420
+
421
+ +----------------------+
422
+
423
+ | Tables_in_laboratory |
424
+
425
+ +----------------------+
426
+
427
+ | failed_jobs |
428
+
429
+ | lab_evaluation |
430
+
431
+ | laboratories |
432
+
433
+ | migrations |
434
+
435
+ | password_resets |
436
+
437
+ | users |
438
+
439
+ +----------------------+
440
+
441
+ 6 rows in set (0.001 sec)
442
+
443
+
444
+
445
+ MariaDB [laboratory]> desc laboratories
446
+
447
+ -> ;
448
+
449
+ +----------------+---------------------+------+-----+---------+----------------+
450
+
451
+ | Field | Type | Null | Key | Default | Extra |
452
+
453
+ +----------------+---------------------+------+-----+---------+----------------+
454
+
455
+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
456
+
457
+ | lab_name | varchar(191) | NO | | NULL | |
458
+
459
+ | lab_univ | varchar(191) | NO | | NULL | |
460
+
461
+ | lab_evaluation | double(2,1) | NO | | NULL | |
462
+
463
+ | add_time | date | NO | | NULL | |
464
+
465
+ | created_at | timestamp | YES | | NULL | |
466
+
467
+ | updated_at | timestamp | YES | | NULL | |
468
+
469
+ +----------------+---------------------+------+-----+---------+----------------+
470
+
471
+ 7 rows in set (0.061 sec)
472
+
473
+
474
+
413
- ![イメージ説明](1271bcc16aefe5ffdd998d23693f7b9d.png)
475
+ MariaDB [laboratory]> desc lab_evaluation;
476
+
477
+ +------------+---------------------+------+-----+---------+----------------+
478
+
479
+ | Field | Type | Null | Key | Default | Extra |
480
+
481
+ +------------+---------------------+------+-----+---------+----------------+
482
+
483
+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
484
+
485
+ | created_at | timestamp | YES | | NULL | |
486
+
487
+ | updated_at | timestamp | YES | | NULL | |
488
+
489
+ +------------+---------------------+------+-----+---------+----------------+
490
+
491
+ 3 rows in set (0.031 sec)
492
+
493
+ ```

2

テーブルの構造を追記

2020/07/14 07:52

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -407,3 +407,7 @@
407
407
 
408
408
 
409
409
  ```
410
+
411
+
412
+
413
+ ![イメージ説明](1271bcc16aefe5ffdd998d23693f7b9d.png)

1

コントローラー及び、web.phpの追記

2020/07/14 06:01

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -231,3 +231,179 @@
231
231
 
232
232
 
233
233
  他にも必要な情報があれば教えてください。
234
+
235
+
236
+
237
+ ---
238
+
239
+ ### 追記
240
+
241
+
242
+
243
+ ```web.php
244
+
245
+ <?php
246
+
247
+
248
+
249
+ use App\Laboratory;
250
+
251
+ use Illuminate\Http\Request;
252
+
253
+
254
+
255
+ //エラー表示を適切にするため
256
+
257
+ Route::group(['middleware' => ['web']], function ()
258
+
259
+ {
260
+
261
+ //研究室サイトダッシュボード表示
262
+
263
+ Route::get('/', 'LabController@index');
264
+
265
+
266
+
267
+ //研究室の追加
268
+
269
+ Route::post('/laboratories', 'LabController@store');
270
+
271
+
272
+
273
+ //研究室の評価追加
274
+
275
+ Route::post('/laboratory/{laboratory}', 'LabController@store_evaluation');
276
+
277
+
278
+
279
+ Route::post('/', 'LabController@mv_add');
280
+
281
+
282
+
283
+ //更新画面
284
+
285
+ Route::post('/labedit/{laboratories}','LabController@mv_update');
286
+
287
+
288
+
289
+ //更新処理
290
+
291
+ Route::post('/laboratories/update', 'LabController@update');
292
+
293
+
294
+
295
+ //削除処理
296
+
297
+ Route::delete('/laboratory/{laboratory}', 'LabController@delete');
298
+
299
+
300
+
301
+ Auth::routes(); //認証機能を使用する。
302
+
303
+
304
+
305
+ Route::get('/home', 'HomeController@index')->name('home');
306
+
307
+
308
+
309
+
310
+
311
+ //========リンク設定========================================
312
+
313
+ //TO:研究室の情報追加ページ
314
+
315
+ Route::get('/add', 'LinkController@to_add');
316
+
317
+
318
+
319
+ //TO:研究室の情報追加ページ
320
+
321
+ Route::get('/add_evaluation', 'LinkController@to_add_evaluation');
322
+
323
+
324
+
325
+ //TO:各大学ページ
326
+
327
+ Route::get('/univ/{univ_name}','LinkController@to_univ');
328
+
329
+
330
+
331
+ //TO:各研究室ページ
332
+
333
+ Route::get('/lab/{lab_details}','LinkController@to_lab_details');
334
+
335
+ });
336
+
337
+
338
+
339
+ ```
340
+
341
+
342
+
343
+ ```LabController(該当部のみ)
344
+
345
+
346
+
347
+ public function store_evaluation(Request $request)
348
+
349
+ {
350
+
351
+ $validator = Validator::make($request->all(), [
352
+
353
+ 'professor' => 'required|min:1|max:5',
354
+
355
+ 'employment' => 'required|min:1|max:5',
356
+
357
+ 'atmosphere' => 'required|min:1|max:5',
358
+
359
+ 'facility' => 'required|min:1|max:5',
360
+
361
+ 'skill' => 'required|min:1|max:5',
362
+
363
+ ]);
364
+
365
+
366
+
367
+ //バリテーション:エラー
368
+
369
+ if($validator->fails()) {
370
+
371
+ return redirect('/laboratory/{laboratory}')
372
+
373
+ ->withInput()
374
+
375
+ ->withError($validator);
376
+
377
+ }
378
+
379
+
380
+
381
+ //研究室のDBにデータを格納
382
+
383
+ //Eloquentモデル (=MySQL記述なしにデータベース管理をしてくれる)
384
+
385
+ $today = date("Y/m/d"); //現在時刻の取得
386
+
387
+ $lab_evaluation = new lab_evaluation;
388
+
389
+ $lab_evaluation->professor = $request->professor;
390
+
391
+ $lab_evaluation->employment = $request->employment;
392
+
393
+ $lab_evaluation->atmosphere = $request->atmosphere;
394
+
395
+ $lab_evaluation->facility = $request->facility;
396
+
397
+ $lab_evaluation->skill = $request->skill;
398
+
399
+ $lab_evaluation->add_time = $today;
400
+
401
+ $lab_evaluation->save();
402
+
403
+ return redirect('/laboratory/{laboratory}');
404
+
405
+ }
406
+
407
+
408
+
409
+ ```