質問編集履歴
2
Tnker結果などを追記
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -308,4 +308,62 @@
|
|
|
308
308
|
Schema::dropIfExists('answers');
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
+
```
|
|
312
|
+
Tinker実行結果
|
|
313
|
+
```ここに言語を入力
|
|
314
|
+
>>> App\Quiz::all();
|
|
315
|
+
=> Illuminate\Database\Eloquent\Collection {#3268
|
|
316
|
+
all: [
|
|
317
|
+
App\Quiz {#3269
|
|
318
|
+
id: "1",
|
|
319
|
+
title: "パソコン(PC)は何の略か。",
|
|
320
|
+
image_src: null,
|
|
321
|
+
answers_id: "1",
|
|
322
|
+
created_at: "2021-02-05 20:12:53",
|
|
323
|
+
updated_at: "2021-02-05 20:12:53",
|
|
324
|
+
},
|
|
325
|
+
App\Quiz {#3270
|
|
326
|
+
id: "2",
|
|
327
|
+
title: "アプリケーションをコンピュータで使用可能にするための作業のことを何と言うか。",
|
|
328
|
+
image_src: null,
|
|
329
|
+
answers_id: "2",
|
|
330
|
+
created_at: "2021-02-05 20:12:53",
|
|
331
|
+
updated_at: "2021-02-05 20:12:53",
|
|
332
|
+
},
|
|
333
|
+
App\Quiz {#3271
|
|
334
|
+
id: "3",
|
|
335
|
+
title: "中央処理装置とも訳されるコンピュータの情報処理の性能に影響する部分の略称は。Intel社製が多い。",
|
|
336
|
+
image_src: null,
|
|
337
|
+
answers_id: "3",
|
|
338
|
+
created_at: "2017-10-04 21:00:00",
|
|
339
|
+
updated_at: "2021-02-05 20:12:53",
|
|
340
|
+
},
|
|
341
|
+
App\Quiz {#3272
|
|
342
|
+
id: "4",
|
|
343
|
+
title: "情報を記録し読み出す代表的な記憶装置の一つ。PCに内蔵されている円盤状の磁気ディスク。",
|
|
344
|
+
image_src: null,
|
|
345
|
+
answers_id: "4",
|
|
346
|
+
created_at: "2021-02-05 20:12:53",
|
|
347
|
+
updated_at: "2021-02-05 20:12:53",
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
localhost:8000/api/quizにアクセスした結果
|
|
354
|
+
|
|
355
|
+
```ここに言語を入力
|
|
356
|
+
// 20210207084833
|
|
357
|
+
// http://localhost:8000/api/quiz
|
|
358
|
+
|
|
359
|
+
[
|
|
360
|
+
{
|
|
361
|
+
"id": 1,
|
|
362
|
+
"title": "パソコン(PC)は何の略か。",
|
|
363
|
+
"image_src": null,
|
|
364
|
+
"answers_id": "1",
|
|
365
|
+
"created_at": "2021-02-05 20:12:53",
|
|
366
|
+
"updated_at": "2021-02-05 20:12:53"
|
|
367
|
+
}
|
|
368
|
+
]
|
|
311
369
|
```
|
1
クイズとアンサーテーブルを追記しました
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -230,4 +230,82 @@
|
|
|
230
230
|
|
|
231
231
|
};
|
|
232
232
|
</script>
|
|
233
|
+
```
|
|
234
|
+
追記
|
|
235
|
+
**create_quizs_table**
|
|
236
|
+
```ここに言語を入力
|
|
237
|
+
<?php
|
|
238
|
+
|
|
239
|
+
use Illuminate\Database\Migrations\Migration;
|
|
240
|
+
use Illuminate\Database\Schema\Blueprint;
|
|
241
|
+
use Illuminate\Support\Facades\Schema;
|
|
242
|
+
|
|
243
|
+
class CreateQuizzesTable extends Migration
|
|
244
|
+
{
|
|
245
|
+
/**
|
|
246
|
+
* Run the migrations.
|
|
247
|
+
*
|
|
248
|
+
* @return void
|
|
249
|
+
*/
|
|
250
|
+
public function up()
|
|
251
|
+
{
|
|
252
|
+
Schema::create('quizzes', function (Blueprint $table) {
|
|
253
|
+
$table->bigIncrements('id');
|
|
254
|
+
$table->text('title');
|
|
255
|
+
$table->string('image_src')->nullable();
|
|
256
|
+
$table->integer('answers_id');
|
|
257
|
+
$table->timestamps();
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Reverse the migrations.
|
|
263
|
+
*
|
|
264
|
+
* @return void
|
|
265
|
+
*/
|
|
266
|
+
public function down()
|
|
267
|
+
{
|
|
268
|
+
Schema::dropIfExists('quizzes');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
create_answer_table
|
|
273
|
+
```php
|
|
274
|
+
<?php
|
|
275
|
+
|
|
276
|
+
use Illuminate\Database\Migrations\Migration;
|
|
277
|
+
use Illuminate\Database\Schema\Blueprint;
|
|
278
|
+
use Illuminate\Support\Facades\Schema;
|
|
279
|
+
|
|
280
|
+
class CreateAnswersTable extends Migration
|
|
281
|
+
{
|
|
282
|
+
/**
|
|
283
|
+
* Run the migrations.
|
|
284
|
+
*
|
|
285
|
+
* @return void
|
|
286
|
+
*/
|
|
287
|
+
public function up()
|
|
288
|
+
{
|
|
289
|
+
Schema::create('answers', function (Blueprint $table) {
|
|
290
|
+
$table->bigIncrements('id');
|
|
291
|
+
$table->string('answer_1');
|
|
292
|
+
$table->string('answer_2');
|
|
293
|
+
$table->string('answer_3');
|
|
294
|
+
$table->string('answer_4');
|
|
295
|
+
$table->integer('correct_answer_no');
|
|
296
|
+
$table->text('commentary');
|
|
297
|
+
$table->timestamps();
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Reverse the migrations.
|
|
303
|
+
*
|
|
304
|
+
* @return void
|
|
305
|
+
*/
|
|
306
|
+
public function down()
|
|
307
|
+
{
|
|
308
|
+
Schema::dropIfExists('answers');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
233
311
|
```
|