質問編集履歴

1

voting.blade.phpで表示したいarticle_create_table.phpとdd(articles)の処理結果(一部を)を追加しました。

2021/01/03 10:19

投稿

ingramzero
ingramzero

スコア16

test CHANGED
File without changes
test CHANGED
@@ -6,6 +6,108 @@
6
6
 
7
7
 
8
8
 
9
+
10
+
11
+ 以下テーブル定義
12
+
13
+ 以下のarticleカラムをvoting.blade.phpで表示したい。
14
+
15
+ create_article_table.php
16
+
17
+ ---
18
+
19
+
20
+
21
+ ```
22
+
23
+ <?php
24
+
25
+
26
+
27
+ use Illuminate\Database\Migrations\Migration;
28
+
29
+ use Illuminate\Database\Schema\Blueprint;
30
+
31
+ use Illuminate\Support\Facades\Schema;
32
+
33
+
34
+
35
+ class CreateArticlesTable extends Migration
36
+
37
+ {
38
+
39
+ /**
40
+
41
+ * Run the migrations.
42
+
43
+ *
44
+
45
+ * @return void
46
+
47
+ */
48
+
49
+ public function up()
50
+
51
+ {
52
+
53
+ Schema::create('articles', function (Blueprint $table) {
54
+
55
+ $table->id();
56
+
57
+ $table->string('article');
58
+
59
+ $table->string('article_title');
60
+
61
+ $table->timestamps();
62
+
63
+ $table->integer('user_id')->unsigned()->default();
64
+
65
+ $table->foreign('user_id') //外部キー制約
66
+
67
+ ->references('id')
68
+
69
+ ->on('users')//usersテーブルのidを参照する
70
+
71
+ ->onDelete('cascade');//ユーザーが削除されたら紐付くpostsも削除
72
+
73
+ });
74
+
75
+ }
76
+
77
+
78
+
79
+ /**
80
+
81
+ * Reverse the migrations.
82
+
83
+ *
84
+
85
+ * @return void
86
+
87
+ */
88
+
89
+ public function down()
90
+
91
+ {
92
+
93
+
94
+
95
+ Schema::dropIfExists('articles');
96
+
97
+
98
+
99
+ }
100
+
101
+ }
102
+
103
+
104
+
105
+ ```
106
+
107
+
108
+
109
+
110
+
9
111
  votings.blade.php
10
112
 
11
113
  ---
@@ -124,4 +226,156 @@
124
226
 
125
227
 
126
228
 
229
+ ```
230
+
231
+ #items: array:9 [▼
232
+
233
+ 0 => App\Models\Article {#1245 ▼
234
+
235
+ #connection: "sqlite"
236
+
237
+ #table: "articles"
238
+
239
+ #primaryKey: "id"
240
+
241
+ #keyType: "int"
242
+
243
+ +incrementing: true
244
+
245
+ #with: []
246
+
247
+ #withCount: []
248
+
249
+ #perPage: 15
250
+
251
+ +exists: true
252
+
253
+ +wasRecentlyCreated: false
254
+
255
+ #attributes: array:1 [▼
256
+
127
- ![イメージ説明](e911a3e51baf7364533540ff63b8952d.png)
257
+ "article" => "てすと"
258
+
259
+ ]
260
+
261
+ #original: array:1 [▼
262
+
263
+ "article" => "てすと"
264
+
265
+ ]
266
+
267
+ #changes: []
268
+
269
+ #casts: []
270
+
271
+ #classCastCache: []
272
+
273
+ #dates: []
274
+
275
+ #dateFormat: null
276
+
277
+ #appends: []
278
+
279
+ #dispatchesEvents: []
280
+
281
+ #observables: []
282
+
283
+ #relations: []
284
+
285
+ #touches: []
286
+
287
+ +timestamps: true
288
+
289
+ #hidden: []
290
+
291
+ #visible: []
292
+
293
+ #fillable: []
294
+
295
+ #guarded: array:1 [▶]
296
+
297
+ }
298
+
299
+ 1 => App\Models\Article {#1246 ▼
300
+
301
+ #connection: "sqlite"
302
+
303
+ #table: "articles"
304
+
305
+ #primaryKey: "id"
306
+
307
+ #keyType: "int"
308
+
309
+ +incrementing: true
310
+
311
+ #with: []
312
+
313
+ #withCount: []
314
+
315
+ #perPage: 15
316
+
317
+ +exists: true
318
+
319
+ +wasRecentlyCreated: false
320
+
321
+ #attributes: array:1 [▶]
322
+
323
+ #original: array:1 [▶]
324
+
325
+ #changes: []
326
+
327
+ #casts: []
328
+
329
+ #classCastCache: []
330
+
331
+ #dates: []
332
+
333
+ #dateFormat: null
334
+
335
+ #appends: []
336
+
337
+ #dispatchesEvents: []
338
+
339
+ #observables: []
340
+
341
+ #relations: []
342
+
343
+ #touches: []
344
+
345
+ +timestamps: true
346
+
347
+ #hidden: []
348
+
349
+ #visible: []
350
+
351
+ #fillable: []
352
+
353
+ #guarded: array:1 [▼
354
+
355
+ 0 => "*"
356
+
357
+ ]
358
+
359
+ }
360
+
361
+ 2 => App\Models\Article {#1247 ▶}
362
+
363
+ 3 => App\Models\Article {#1248 ▶}
364
+
365
+ 4 => App\Models\Article {#1249 ▶}
366
+
367
+ 5 => App\Models\Article {#1250 ▶}
368
+
369
+ 6 => App\Models\Article {#1251 ▶}
370
+
371
+ 7 => App\Models\Article {#1252 ▶}
372
+
373
+ 8 => App\Models\Article {#1253 ▶}
374
+
375
+ ]
376
+
377
+ }
378
+
379
+
380
+
381
+ ```