質問編集履歴

1

周辺ファイル追記しました。

2018/10/14 09:10

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- docker + laravel で composer dump-autoloadをしたい。
1
+ docker + laravel で seed をしたい。
test CHANGED
@@ -13,3 +13,177 @@
13
13
  しかし、dockerでの開発のため、どのように実行したらいいか正確なコードが得られませんでした。
14
14
 
15
15
  どのようにしたらいいか、正解を知っている方がいましたら教えてください。
16
+
17
+
18
+
19
+ 下記周辺ファイルを追記しておきます。
20
+
21
+
22
+
23
+ ```DatabaseSeeder
24
+
25
+ <?php
26
+
27
+
28
+
29
+ use Illuminate\Database\Seeder;
30
+
31
+
32
+
33
+ class DatabaseSeeder extends Seeder
34
+
35
+ {
36
+
37
+ /**
38
+
39
+ * Seed the application's database.
40
+
41
+ *
42
+
43
+ * @return void
44
+
45
+ */
46
+
47
+ public function run()
48
+
49
+ {
50
+
51
+ $this->call(UsersTableSeeder::class);
52
+
53
+ }
54
+
55
+ }
56
+
57
+
58
+
59
+ ```
60
+
61
+
62
+
63
+ ```UsersTableSeeder
64
+
65
+ <?php
66
+
67
+
68
+
69
+ use Illuminate\Database\Seeder;
70
+
71
+
72
+
73
+ class UsersTableSeeder extends Seeder
74
+
75
+ {
76
+
77
+ /**
78
+
79
+ * Run the database seeds.
80
+
81
+ *
82
+
83
+ * @return void
84
+
85
+ */
86
+
87
+ public function run()
88
+
89
+ {
90
+
91
+ $param =[
92
+
93
+ 'name' => 'name',
94
+
95
+ 'email' => 'fugafuga@example.com',
96
+
97
+ 'password' => 'hogehoge',
98
+
99
+ ];
100
+
101
+ DB::table('users')->insert($param);
102
+
103
+ }
104
+
105
+ }
106
+
107
+
108
+
109
+ ```
110
+
111
+
112
+
113
+ ```CreateUsersTable
114
+
115
+ <?php
116
+
117
+
118
+
119
+ use Illuminate\Support\Facades\Schema;
120
+
121
+ use Illuminate\Database\Schema\Blueprint;
122
+
123
+ use Illuminate\Database\Migrations\Migration;
124
+
125
+
126
+
127
+ class CreateUsersTable extends Migration
128
+
129
+ {
130
+
131
+ /**
132
+
133
+ * Run the migrations.
134
+
135
+ *
136
+
137
+ * @return void
138
+
139
+ */
140
+
141
+ public function up()
142
+
143
+ {
144
+
145
+ Schema::create('users', function (Blueprint $table) {
146
+
147
+ $table->increments('id');
148
+
149
+ $table->string('name');
150
+
151
+ $table->string('email')->unique();
152
+
153
+ $table->timestamp('email_verified_at')->nullable();
154
+
155
+ $table->string('password');
156
+
157
+ $table->rememberToken();
158
+
159
+ $table->timestamps();
160
+
161
+ });
162
+
163
+ }
164
+
165
+
166
+
167
+ /**
168
+
169
+ * Reverse the migrations.
170
+
171
+ *
172
+
173
+ * @return void
174
+
175
+ */
176
+
177
+ public function down()
178
+
179
+ {
180
+
181
+ Schema::dropIfExists('users');
182
+
183
+ }
184
+
185
+ }
186
+
187
+
188
+
189
+ ```