質問編集履歴
2
バージョン情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -310,6 +310,6 @@
|
|
310
310
|
|
311
311
|
php 5.6.8
|
312
312
|
|
313
|
-
laravel 5
|
313
|
+
laravel 5.2
|
314
314
|
|
315
315
|
composer 1.4.2
|
1
コードの編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,10 +26,138 @@
|
|
26
26
|
|
27
27
|
```php
|
28
28
|
|
29
|
+
<?php
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
namespace App\Http\Controllers\Auth;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
use App\User;
|
38
|
+
|
39
|
+
use Validator;
|
40
|
+
|
41
|
+
use App\Http\Controllers\Controller;
|
42
|
+
|
43
|
+
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
44
|
+
|
45
|
+
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
46
|
+
|
47
|
+
use Image;
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
class AuthController extends Controller
|
52
|
+
|
53
|
+
{
|
54
|
+
|
55
|
+
/*
|
56
|
+
|
57
|
+
|--------------------------------------------------------------------------
|
58
|
+
|
59
|
+
| Registration & Login Controller
|
60
|
+
|
61
|
+
|--------------------------------------------------------------------------
|
62
|
+
|
63
|
+
|
|
64
|
+
|
65
|
+
| This controller handles the registration of new users, as well as the
|
66
|
+
|
67
|
+
| authentication of existing users. By default, this controller uses
|
68
|
+
|
69
|
+
| a simple trait to add these behaviors. Why don't you explore it?
|
70
|
+
|
71
|
+
|
|
72
|
+
|
73
|
+
*/
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
/**
|
82
|
+
|
83
|
+
* Where to redirect users after login / registration.
|
84
|
+
|
85
|
+
*
|
86
|
+
|
87
|
+
* @var string
|
88
|
+
|
89
|
+
*/
|
90
|
+
|
91
|
+
protected $redirectTo = '/';
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
/**
|
96
|
+
|
97
|
+
* Create a new authentication controller instance.
|
98
|
+
|
99
|
+
*
|
100
|
+
|
101
|
+
* @return void
|
102
|
+
|
103
|
+
*/
|
104
|
+
|
29
|
-
p
|
105
|
+
public function __construct()
|
30
106
|
|
31
107
|
{
|
32
108
|
|
109
|
+
$this->middleware('guest', ['except' => 'logout']);
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
/**
|
116
|
+
|
117
|
+
* Get a validator for an incoming registration request.
|
118
|
+
|
119
|
+
*
|
120
|
+
|
121
|
+
* @param array $data
|
122
|
+
|
123
|
+
* @return \Illuminate\Contracts\Validation\Validator
|
124
|
+
|
125
|
+
*/
|
126
|
+
|
127
|
+
protected function validator(array $data)
|
128
|
+
|
129
|
+
{
|
130
|
+
|
131
|
+
return Validator::make($data, [
|
132
|
+
|
133
|
+
'name' => 'required|max:255',
|
134
|
+
|
135
|
+
'email' => 'required|email|max:255|unique:users',
|
136
|
+
|
137
|
+
'password' => 'required|confirmed|min:6',
|
138
|
+
|
139
|
+
]);
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
/**
|
146
|
+
|
147
|
+
* Create a new user instance after a valid registration.
|
148
|
+
|
149
|
+
*
|
150
|
+
|
151
|
+
* @param array $data
|
152
|
+
|
153
|
+
* @return User
|
154
|
+
|
155
|
+
*/
|
156
|
+
|
157
|
+
protected function create(array $data)
|
158
|
+
|
159
|
+
{
|
160
|
+
|
33
161
|
$fileName = $data['avatar']->getClientOriginalName();
|
34
162
|
|
35
163
|
Image::make($data['avatar'])->save(public_path() . '/images/' . $fileName);
|
@@ -38,35 +166,139 @@
|
|
38
166
|
|
39
167
|
return User::create([
|
40
168
|
|
169
|
+
'name' => $data['name'],
|
170
|
+
|
171
|
+
'email' => $data['email'],
|
172
|
+
|
173
|
+
'password' => bcrypt($data['password']),
|
174
|
+
|
41
175
|
'avatar' => $fileName,
|
42
176
|
|
43
177
|
]);
|
44
178
|
|
179
|
+
}
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
45
185
|
```
|
46
186
|
|
47
187
|
フォームです。
|
48
188
|
|
49
189
|
```php
|
50
190
|
|
191
|
+
@extends('layout')
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
@section('content')
|
196
|
+
|
197
|
+
<div class="bgcolor-white pt1em pb1em" id="contents">
|
198
|
+
|
199
|
+
<div id="main_cnt_wrapper">
|
200
|
+
|
201
|
+
<div id="yjContentsBody">
|
202
|
+
|
203
|
+
<div class="yjContainer">
|
204
|
+
|
205
|
+
<div class="form_box">
|
206
|
+
|
207
|
+
<h2>m<span>新規登録</span></h2>
|
208
|
+
|
51
|
-
{!! Form::open(array('files' => true)) !!}
|
209
|
+
{!! Form::open(array('files' => true)) !!}
|
210
|
+
|
52
|
-
|
211
|
+
@if (count($errors) > 0)
|
212
|
+
|
213
|
+
<div id="error_explanation">
|
214
|
+
|
215
|
+
<ul>
|
216
|
+
|
217
|
+
@foreach ($errors->all() as $error)
|
218
|
+
|
219
|
+
<li>{{ $error }}</li>
|
220
|
+
|
221
|
+
@endforeach
|
222
|
+
|
223
|
+
</ul>
|
224
|
+
|
225
|
+
</div>
|
226
|
+
|
227
|
+
@endif
|
228
|
+
|
229
|
+
<div class="label">
|
230
|
+
|
231
|
+
{{ Form::label('email') }}
|
232
|
+
|
233
|
+
{{ Form::email('email', '', ['placeholder' => 'メールアドレスを入力']) }}
|
234
|
+
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<div class="label">
|
238
|
+
|
239
|
+
{{ Form::label('password') }}
|
240
|
+
|
241
|
+
{{ Form::password('password', ['placeholder' => 'パスワードを入力']) }}
|
242
|
+
|
243
|
+
</div>
|
244
|
+
|
245
|
+
<div class="label">
|
246
|
+
|
247
|
+
{{ Form::label('password_confirmation') }}
|
248
|
+
|
249
|
+
{{ Form::password('password_confirmation', ['placeholder' => 'パスワードを入力(確認)']) }}
|
250
|
+
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<div class="label">
|
254
|
+
|
255
|
+
{{ Form::label('name') }}
|
256
|
+
|
257
|
+
{{ Form::text('name') }}
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
53
|
-
<div class="field">
|
261
|
+
<div class="field">
|
54
|
-
|
262
|
+
|
55
|
-
{{ Form::file('avatar') }}
|
263
|
+
{{ Form::file('avatar') }}
|
56
|
-
|
264
|
+
|
57
|
-
</div>
|
265
|
+
</div>
|
58
|
-
|
266
|
+
|
267
|
+
|
268
|
+
|
59
|
-
|
269
|
+
<div class="submit">
|
60
|
-
|
270
|
+
|
61
|
-
|
271
|
+
<div class="actions">
|
62
|
-
|
272
|
+
|
63
|
-
|
273
|
+
{{ Form::submit('Create User', ['class' => 'btn btn--block']) }}
|
274
|
+
|
275
|
+
</div>
|
276
|
+
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
{!! Form::close() !!}
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
<div class="more_link_box">
|
286
|
+
|
287
|
+
<strong>すでにアカウントを持っていますか?</strong>
|
288
|
+
|
289
|
+
<a href="/login">Log in</a>
|
290
|
+
|
291
|
+
</div>
|
292
|
+
|
293
|
+
</div>
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
</div>
|
64
298
|
|
65
299
|
</div>
|
66
300
|
|
67
|
-
|
301
|
+
@endsection
|
68
|
-
|
69
|
-
{!! Form::close() !!}
|
70
302
|
|
71
303
|
```
|
72
304
|
|