質問編集履歴
2
Quizcontrollerとapi.phpについて追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -418,7 +418,21 @@
|
|
418
418
|
|
419
419
|
```
|
420
420
|
|
421
|
-
|
421
|
+
api.php
|
422
|
+
|
423
|
+
```ここに言語を入力
|
424
|
+
|
425
|
+
Route::group(['middleware' => ['api']], function () {
|
426
|
+
|
427
|
+
Route::get('quiz', 'Api\QuizController@show');
|
428
|
+
|
429
|
+
Route::post('quiz', 'Api\QuizController@store');
|
430
|
+
|
431
|
+
});
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
```
|
422
436
|
|
423
437
|
Quiz Controller.php
|
424
438
|
|
@@ -444,26 +458,36 @@
|
|
444
458
|
|
445
459
|
{
|
446
460
|
|
447
|
-
public function show(
|
461
|
+
public function show()
|
448
462
|
|
449
463
|
{
|
450
464
|
|
451
|
-
|
452
|
-
|
453
465
|
$quiz = cache('quiz');
|
454
466
|
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
467
|
return $quiz;
|
460
468
|
|
461
469
|
}
|
462
470
|
|
471
|
+
|
472
|
+
|
473
|
+
public function store(Request $request)
|
474
|
+
|
475
|
+
{
|
476
|
+
|
477
|
+
$request->session()->put('Answertime', 19);
|
478
|
+
|
479
|
+
$isAnswer = $request->session()->get('Answertime');
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
}
|
484
|
+
|
463
485
|
}
|
464
486
|
|
465
487
|
|
466
488
|
|
489
|
+
|
490
|
+
|
467
491
|
```
|
468
492
|
|
469
493
|
Usersテーブル
|
1
QuizControllerとUsersテーブルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -417,3 +417,131 @@
|
|
417
417
|
});
|
418
418
|
|
419
419
|
```
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
Quiz Controller.php
|
424
|
+
|
425
|
+
```ここに言語を入力
|
426
|
+
|
427
|
+
<?php
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
namespace App\Http\Controllers\Api;
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
use App\Http\Controllers\Controller;
|
436
|
+
|
437
|
+
use Illuminate\Http\Request;
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
class QuizController extends Controller
|
444
|
+
|
445
|
+
{
|
446
|
+
|
447
|
+
public function show(Request $request)
|
448
|
+
|
449
|
+
{
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
$quiz = cache('quiz');
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
return $quiz;
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
```
|
468
|
+
|
469
|
+
Usersテーブル
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
```ここに言語を入力
|
474
|
+
|
475
|
+
<?php
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
use Illuminate\Database\Migrations\Migration;
|
480
|
+
|
481
|
+
use Illuminate\Database\Schema\Blueprint;
|
482
|
+
|
483
|
+
use Illuminate\Support\Facades\Schema;
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
class CreateUsersTable extends Migration
|
488
|
+
|
489
|
+
{
|
490
|
+
|
491
|
+
/**
|
492
|
+
|
493
|
+
* Run the migrations.
|
494
|
+
|
495
|
+
*
|
496
|
+
|
497
|
+
* @return void
|
498
|
+
|
499
|
+
*/
|
500
|
+
|
501
|
+
public function up()
|
502
|
+
|
503
|
+
{
|
504
|
+
|
505
|
+
Schema::create('users', function (Blueprint $table) {
|
506
|
+
|
507
|
+
$table->bigIncrements('id');
|
508
|
+
|
509
|
+
$table->string('name');
|
510
|
+
|
511
|
+
$table->string('email')->unique();
|
512
|
+
|
513
|
+
$table->timestamp('email_verified_at')->nullable();
|
514
|
+
|
515
|
+
$table->string('password');
|
516
|
+
|
517
|
+
$table->rememberToken();
|
518
|
+
|
519
|
+
$table->timestamps();
|
520
|
+
|
521
|
+
});
|
522
|
+
|
523
|
+
}
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
/**
|
528
|
+
|
529
|
+
* Reverse the migrations.
|
530
|
+
|
531
|
+
*
|
532
|
+
|
533
|
+
* @return void
|
534
|
+
|
535
|
+
*/
|
536
|
+
|
537
|
+
public function down()
|
538
|
+
|
539
|
+
{
|
540
|
+
|
541
|
+
Schema::dropIfExists('users');
|
542
|
+
|
543
|
+
}
|
544
|
+
|
545
|
+
}
|
546
|
+
|
547
|
+
```
|