teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

エラーと.phpの編集

2019/07/28 05:13

投稿

Ms.yy
Ms.yy

スコア83

title CHANGED
File without changes
body CHANGED
@@ -10,19 +10,15 @@
10
10
 
11
11
  In Connection.php line 664:
12
12
 
13
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'title' in 'field li
13
+ SQLSTATE[HY000]: General error: 1364 Field 'body' doesn't have a default va
14
- st' (SQL: insert into `posts` (`title`, `body`, `updated_at`, `created_at`)
14
+ lue (SQL: insert into `comments` (`post_id`, `updated_at`, `created_at`) va
15
- values (投稿のタイトル, 本文です。テキストテキストテキストテキストテキスト
16
- テキストテキストテキストテキストテキスト。
17
- テキストテキストテキストテキストテキストテキストテキストテキストテキストテ
18
- キスト。テキストテキストテキストテキストテキストテキストテキストテキストテ
19
- キストテキスト。, 2019-07-28 01:07:40, 2019-07-28 01:07:40))
15
+ lues (1, 2019-07-28 05:02:00, 2019-07-28 05:02:00))
20
16
 
21
17
 
22
- In Connection.php line 452:
18
+ In Connection.php line 458:
23
19
 
24
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'title' in 'field li
20
+ SQLSTATE[HY000]: General error: 1364 Field 'body' doesn't have a default va
25
- st'
21
+ lue
26
22
 
27
23
  ```
28
24
 
@@ -45,72 +41,36 @@
45
41
  $this->call(PostsTableSeeder::class);
46
42
  }}
47
43
  ```
48
-
49
-
50
-  ### DatabaseSeeder.php
51
-
52
- ```ここに言語名を入力
53
- ### PostTableSeeder.php
44
+ ### postfactry.php
54
-
45
+ ```
55
-
56
46
  <?php
57
47
 
58
- use Illuminate\Database\Seeder;
48
+ use Faker\Generator as Faker;
59
49
 
60
- class DatabaseSeeder extends Seeder
61
- {
62
- /**
63
- * Seed the application's database.
50
+ $factory->define(App\Post::class, function (Faker $faker) {
64
- *
65
- * @return void
51
+ return [
66
- */
67
- public function run()
68
- {
69
- $this->call(PostsTableSeeder::class);
52
+ 'title' => '投稿のタイトル',
53
+ 'body' => "本文です。テキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト。\nテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト。テキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト。",
54
+ ];
70
- }}
55
+ });
56
+ ```
71
57
 
58
+ ### userfactry.php
72
59
  ```
73
-
74
- ### DatabaseSeeder.php
75
-
76
- ```ここに言語名を入力
77
60
  <?php
78
61
 
79
- use Illuminate\Database\Seeder;
62
+ use Faker\Generator as Faker;
80
63
 
81
- class DatabaseSeeder extends Seeder
82
- {
83
- /**
84
- * Seed the application's database.
64
+ $factory->define(App\Comment::class, function (Faker $faker) {
85
- *
86
- * @return void
65
+ return [
66
+ 'body' => "コメントです。テキストテキストテキストテキストテキストテキスト。\nテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト。",
87
- */
67
+ ];
88
- public function run()
89
- {
90
- $this->call(PostsTableSeeder::class);
91
- }}
68
+ });
92
69
  ```
70
+  
93
71
 
94
72
 
95
-  ### DatabaseSeeder.php
96
73
 
97
- ```ここに言語名を入力
98
- ### postテーブルの中身
99
-
100
-
101
- mysql> show columns from posts
102
- -> ;
103
- +------------+------------------+------+-----+---------+----------------+
104
- | Field | Type | Null | Key | Default | Extra |
105
- +------------+------------------+------+-----+---------+----------------+
106
- | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
107
- | created_at | timestamp | YES | | NULL | |
108
- | updated_at | timestamp | YES | | NULL | |
109
- +------------+------------------+------+-----+---------+----------------+
110
- 3 rows in set (0.01 sec)
111
-
112
- ```
113
-
114
74
  ### 補足情報(FW/ツールのバージョンなど)
115
75
 
116
76
  os:mac

2

テーブルの中

2019/07/28 05:13

投稿

Ms.yy
Ms.yy

スコア83

title CHANGED
File without changes
body CHANGED
@@ -71,6 +71,46 @@
71
71
 
72
72
  ```
73
73
 
74
+ ### DatabaseSeeder.php
75
+
76
+ ```ここに言語名を入力
77
+ <?php
78
+
79
+ use Illuminate\Database\Seeder;
80
+
81
+ class DatabaseSeeder extends Seeder
82
+ {
83
+ /**
84
+ * Seed the application's database.
85
+ *
86
+ * @return void
87
+ */
88
+ public function run()
89
+ {
90
+ $this->call(PostsTableSeeder::class);
91
+ }}
92
+ ```
93
+
94
+
95
+  ### DatabaseSeeder.php
96
+
97
+ ```ここに言語名を入力
98
+ ### postテーブルの中身
99
+
100
+
101
+ mysql> show columns from posts
102
+ -> ;
103
+ +------------+------------------+------+-----+---------+----------------+
104
+ | Field | Type | Null | Key | Default | Extra |
105
+ +------------+------------------+------+-----+---------+----------------+
106
+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
107
+ | created_at | timestamp | YES | | NULL | |
108
+ | updated_at | timestamp | YES | | NULL | |
109
+ +------------+------------------+------+-----+---------+----------------+
110
+ 3 rows in set (0.01 sec)
111
+
112
+ ```
113
+
74
114
  ### 補足情報(FW/ツールのバージョンなど)
75
115
 
76
116
  os:mac

1

PostTableSeederの追加

2019/07/28 03:15

投稿

Ms.yy
Ms.yy

スコア83

title CHANGED
File without changes
body CHANGED
@@ -47,8 +47,30 @@
47
47
  ```
48
48
 
49
49
 
50
-  
50
+  ### DatabaseSeeder.php
51
51
 
52
+ ```ここに言語名を入力
53
+ ### PostTableSeeder.php
54
+
55
+
56
+ <?php
57
+
58
+ use Illuminate\Database\Seeder;
59
+
60
+ class DatabaseSeeder extends Seeder
61
+ {
62
+ /**
63
+ * Seed the application's database.
64
+ *
65
+ * @return void
66
+ */
67
+ public function run()
68
+ {
69
+ $this->call(PostsTableSeeder::class);
70
+ }}
71
+
72
+ ```
73
+
52
74
  ### 補足情報(FW/ツールのバージョンなど)
53
75
 
54
76
  os:mac