質問編集履歴

3

追加

2019/03/12 15:38

投稿

sk2938
sk2938

スコア21

test CHANGED
File without changes
test CHANGED
@@ -124,6 +124,156 @@
124
124
 
125
125
  ```
126
126
 
127
+ RegisterController.php
128
+
129
+ ```
130
+
131
+ <?php
132
+
133
+
134
+
135
+ namespace App\Http\Controllers\Auth;
136
+
137
+
138
+
139
+ use App\User;
140
+
141
+ use App\Http\Controllers\Controller;
142
+
143
+ use Illuminate\Support\Facades\Hash;
144
+
145
+ use Illuminate\Support\Facades\Validator;
146
+
147
+ use Illuminate\Foundation\Auth\RegistersUsers;
148
+
149
+
150
+
151
+ class RegisterController extends Controller
152
+
153
+ {
154
+
155
+ /*
156
+
157
+ |--------------------------------------------------------------------------
158
+
159
+ | Register Controller
160
+
161
+ |--------------------------------------------------------------------------
162
+
163
+ |
164
+
165
+ | This controller handles the registration of new users as well as their
166
+
167
+ | validation and creation. By default this controller uses a trait to
168
+
169
+ | provide this functionality without requiring any additional code.
170
+
171
+ |
172
+
173
+ */
174
+
175
+
176
+
177
+ use RegistersUsers;
178
+
179
+
180
+
181
+ /**
182
+
183
+ * Where to redirect users after registration.
184
+
185
+ *
186
+
187
+ * @var string
188
+
189
+ */
190
+
191
+ protected $redirectTo = '/home';
192
+
193
+
194
+
195
+ /**
196
+
197
+ * Create a new controller instance.
198
+
199
+ *
200
+
201
+ * @return void
202
+
203
+ */
204
+
205
+ public function __construct()
206
+
207
+ {
208
+
209
+ $this->middleware('guest');
210
+
211
+ }
212
+
213
+
214
+
215
+ /**
216
+
217
+ * Get a validator for an incoming registration request.
218
+
219
+ *
220
+
221
+ * @param array $data
222
+
223
+ * @return \Illuminate\Contracts\Validation\Validator
224
+
225
+ */
226
+
227
+ protected function validator(array $data)
228
+
229
+ {
230
+
231
+ return Validator::make($data, [
232
+
233
+ 'name' => ['required', 'string', 'max:255'],
234
+
235
+ 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
236
+
237
+ 'password' => ['required', 'string', 'min:8', 'confirmed'],
238
+
239
+ ]);
240
+
241
+ }
242
+
243
+
244
+
245
+ /**
246
+
247
+ * Create a new user instance after a valid registration.
248
+
249
+ *
250
+
251
+ * @param array $data
252
+
253
+ * @return \App\User
254
+
255
+ */
256
+
257
+ protected function create(array $data)
258
+
259
+ {
260
+
261
+ return User::create([
262
+
263
+ 'name' => $data['name'],
264
+
265
+ 'email' => $data['email'],
266
+
267
+ 'password' => Hash::make($data['password']),
268
+
269
+ ]);
270
+
271
+ }
272
+
273
+ }
274
+
275
+ ```
276
+
127
277
 
128
278
 
129
279
  追記

2

追加

2019/03/12 15:38

投稿

sk2938
sk2938

スコア21

test CHANGED
File without changes
test CHANGED
@@ -123,3 +123,13 @@
123
123
  | web |
124
124
 
125
125
  ```
126
+
127
+
128
+
129
+ 追記
130
+
131
+ php artisan make:authコマンドで追加されたApp\Http\Controllers\Auth\RegisterController@showRegistrationForm
132
+
133
+ があって、RegisterControllerのshowRegistrationFormアクションにテンプレートへ送るデータを追加したいのですが、
134
+
135
+ showRegistrationFormアクションが見つけられません。どうやって送ればいいのでしょうか?

1

追加

2019/03/12 15:30

投稿

sk2938
sk2938

スコア21

test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,109 @@
17
17
  }
18
18
 
19
19
  ```
20
+
21
+ php artisan route:list
22
+
23
+ ```
24
+
25
+ | GET|HEAD | api/user | | Closure
26
+
27
+ | api,auth:api |
28
+
29
+ | | GET|HEAD | articles | articles.index | App\Http\Controllers\ArticlesController@index
30
+
31
+ | web |
32
+
33
+ | | POST | articles | articles.store | App\Http\Controllers\ArticlesController@store
34
+
35
+ | web |
36
+
37
+ | | GET|HEAD | articles/create | articles.create | App\Http\Controllers\ArticlesController@create
38
+
39
+ | web |
40
+
41
+ | | GET|HEAD | articles/{article} | articles.show | App\Http\Controllers\ArticlesController@show
42
+
43
+ | web |
44
+
45
+ | | PUT|PATCH | articles/{article} | articles.update | App\Http\Controllers\ArticlesController@update
46
+
47
+ | web |
48
+
49
+ | | DELETE | articles/{article} | articles.destroy | App\Http\Controllers\ArticlesController@destroy
50
+
51
+ | web |
52
+
53
+ | | GET|HEAD | articles/{article}/edit | articles.edit | App\Http\Controllers\ArticlesController@edit
54
+
55
+ | web |
56
+
57
+ | | GET|HEAD | home | home | App\Http\Controllers\HomeController@index
58
+
59
+ | web,auth |
60
+
61
+ | | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm
62
+
63
+ | web,guest |
64
+
65
+ | | POST | login | | App\Http\Controllers\Auth\LoginController@login
66
+
67
+ | web,guest |
68
+
69
+ | | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout
70
+
71
+ | web |
72
+
73
+ | | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail
74
+
75
+ | web,guest |
76
+
77
+ | | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm
78
+
79
+ | web,guest |
80
+
81
+ | | POST | password/reset | password.update | App\Http\Controllers\Auth\ResetPasswordController@reset
82
+
83
+ | web,guest |
84
+
85
+ | | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm
86
+
87
+ | web,guest |
88
+
89
+ | | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm
90
+
91
+ | web,guest |
92
+
93
+ | | POST | register | | App\Http\Controllers\Auth\RegisterController@register
94
+
95
+ | web,guest |
96
+
97
+ | | POST | tags | tags.store | App\Http\Controllers\TagsController@store
98
+
99
+ | web |
100
+
101
+ | | GET|HEAD | tags | tags.index | App\Http\Controllers\TagsController@index
102
+
103
+ | web |
104
+
105
+ | | GET|HEAD | tags/create | tags.create | App\Http\Controllers\TagsController@create
106
+
107
+ | web |
108
+
109
+ | | GET|HEAD | tags/{tag} | tags.show | App\Http\Controllers\TagsController@show
110
+
111
+ | web |
112
+
113
+ | | PUT|PATCH | tags/{tag} | tags.update | App\Http\Controllers\TagsController@update
114
+
115
+ | web |
116
+
117
+ | | DELETE | tags/{tag} | tags.destroy | App\Http\Controllers\TagsController@destroy
118
+
119
+ | web |
120
+
121
+ | | GET|HEAD | tags/{tag}/edit | tags.edit | App\Http\Controllers\TagsController@edit
122
+
123
+ | web |
124
+
125
+ ```