質問編集履歴

2

Tnker結果などを追記

2021/02/07 00:00

投稿

Tikka123456
Tikka123456

スコア34

test CHANGED
File without changes
test CHANGED
@@ -619,3 +619,119 @@
619
619
  }
620
620
 
621
621
  ```
622
+
623
+ Tinker実行結果
624
+
625
+ ```ここに言語を入力
626
+
627
+ >>> App\Quiz::all();
628
+
629
+ => Illuminate\Database\Eloquent\Collection {#3268
630
+
631
+ all: [
632
+
633
+ App\Quiz {#3269
634
+
635
+ id: "1",
636
+
637
+ title: "パソコン(PC)は何の略か。",
638
+
639
+ image_src: null,
640
+
641
+ answers_id: "1",
642
+
643
+ created_at: "2021-02-05 20:12:53",
644
+
645
+ updated_at: "2021-02-05 20:12:53",
646
+
647
+ },
648
+
649
+ App\Quiz {#3270
650
+
651
+ id: "2",
652
+
653
+ title: "アプリケーションをコンピュータで使用可能にするための作業のことを何と言うか。",
654
+
655
+ image_src: null,
656
+
657
+ answers_id: "2",
658
+
659
+ created_at: "2021-02-05 20:12:53",
660
+
661
+ updated_at: "2021-02-05 20:12:53",
662
+
663
+ },
664
+
665
+ App\Quiz {#3271
666
+
667
+ id: "3",
668
+
669
+ title: "中央処理装置とも訳されるコンピュータの情報処理の性能に影響する部分の略称は。Intel社製が多い。",
670
+
671
+ image_src: null,
672
+
673
+ answers_id: "3",
674
+
675
+ created_at: "2017-10-04 21:00:00",
676
+
677
+ updated_at: "2021-02-05 20:12:53",
678
+
679
+ },
680
+
681
+ App\Quiz {#3272
682
+
683
+ id: "4",
684
+
685
+ title: "情報を記録し読み出す代表的な記憶装置の一つ。PCに内蔵されている円盤状の磁気ディスク。",
686
+
687
+ image_src: null,
688
+
689
+ answers_id: "4",
690
+
691
+ created_at: "2021-02-05 20:12:53",
692
+
693
+ updated_at: "2021-02-05 20:12:53",
694
+
695
+ },
696
+
697
+ ],
698
+
699
+ }
700
+
701
+ ```
702
+
703
+
704
+
705
+ localhost:8000/api/quizにアクセスした結果
706
+
707
+
708
+
709
+ ```ここに言語を入力
710
+
711
+ // 20210207084833
712
+
713
+ // http://localhost:8000/api/quiz
714
+
715
+
716
+
717
+ [
718
+
719
+ {
720
+
721
+ "id": 1,
722
+
723
+ "title": "パソコン(PC)は何の略か。",
724
+
725
+ "image_src": null,
726
+
727
+ "answers_id": "1",
728
+
729
+ "created_at": "2021-02-05 20:12:53",
730
+
731
+ "updated_at": "2021-02-05 20:12:53"
732
+
733
+ }
734
+
735
+ ]
736
+
737
+ ```

1

クイズとアンサーテーブルを追記しました

2021/02/07 00:00

投稿

Tikka123456
Tikka123456

スコア34

test CHANGED
File without changes
test CHANGED
@@ -463,3 +463,159 @@
463
463
  </script>
464
464
 
465
465
  ```
466
+
467
+ 追記
468
+
469
+ **create_quizs_table**
470
+
471
+ ```ここに言語を入力
472
+
473
+ <?php
474
+
475
+
476
+
477
+ use Illuminate\Database\Migrations\Migration;
478
+
479
+ use Illuminate\Database\Schema\Blueprint;
480
+
481
+ use Illuminate\Support\Facades\Schema;
482
+
483
+
484
+
485
+ class CreateQuizzesTable extends Migration
486
+
487
+ {
488
+
489
+ /**
490
+
491
+ * Run the migrations.
492
+
493
+ *
494
+
495
+ * @return void
496
+
497
+ */
498
+
499
+ public function up()
500
+
501
+ {
502
+
503
+ Schema::create('quizzes', function (Blueprint $table) {
504
+
505
+ $table->bigIncrements('id');
506
+
507
+ $table->text('title');
508
+
509
+ $table->string('image_src')->nullable();
510
+
511
+ $table->integer('answers_id');
512
+
513
+ $table->timestamps();
514
+
515
+ });
516
+
517
+ }
518
+
519
+
520
+
521
+ /**
522
+
523
+ * Reverse the migrations.
524
+
525
+ *
526
+
527
+ * @return void
528
+
529
+ */
530
+
531
+ public function down()
532
+
533
+ {
534
+
535
+ Schema::dropIfExists('quizzes');
536
+
537
+ }
538
+
539
+ }
540
+
541
+ ```
542
+
543
+ create_answer_table
544
+
545
+ ```php
546
+
547
+ <?php
548
+
549
+
550
+
551
+ use Illuminate\Database\Migrations\Migration;
552
+
553
+ use Illuminate\Database\Schema\Blueprint;
554
+
555
+ use Illuminate\Support\Facades\Schema;
556
+
557
+
558
+
559
+ class CreateAnswersTable extends Migration
560
+
561
+ {
562
+
563
+ /**
564
+
565
+ * Run the migrations.
566
+
567
+ *
568
+
569
+ * @return void
570
+
571
+ */
572
+
573
+ public function up()
574
+
575
+ {
576
+
577
+ Schema::create('answers', function (Blueprint $table) {
578
+
579
+ $table->bigIncrements('id');
580
+
581
+ $table->string('answer_1');
582
+
583
+ $table->string('answer_2');
584
+
585
+ $table->string('answer_3');
586
+
587
+ $table->string('answer_4');
588
+
589
+ $table->integer('correct_answer_no');
590
+
591
+ $table->text('commentary');
592
+
593
+ $table->timestamps();
594
+
595
+ });
596
+
597
+ }
598
+
599
+
600
+
601
+ /**
602
+
603
+ * Reverse the migrations.
604
+
605
+ *
606
+
607
+ * @return void
608
+
609
+ */
610
+
611
+ public function down()
612
+
613
+ {
614
+
615
+ Schema::dropIfExists('answers');
616
+
617
+ }
618
+
619
+ }
620
+
621
+ ```