Merge pull request #266 from shikorism/feature/262-update-mail-address

メールアドレスを変更可能にする
This commit is contained in:
shibafu 2019-09-04 23:50:07 +09:00 committed by GitHub
commit 743272f8d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
class SettingController extends Controller
{
@ -18,10 +19,18 @@ class SettingController extends Controller
$inputs = $request->all();
$validator = Validator::make($inputs, [
'display_name' => 'required|string|max:20',
'email' => [
'required',
'string',
'email',
'max:255',
Rule::unique('users')->ignore(Auth::user()->email, 'email')
],
'bio' => 'nullable|string|max:160',
'url' => 'nullable|url|max:2000'
], [], [
'display_name' => '名前',
'email' => 'メールアドレス',
'bio' => '自己紹介',
'url' => 'URL'
]);
@ -32,6 +41,7 @@ class SettingController extends Controller
$user = Auth::user();
$user->display_name = $inputs['display_name'];
$user->email = $inputs['email'];
$user->bio = $inputs['bio'] ?? '';
$user->url = $inputs['url'] ?? '';
$user->save();

View File

@ -32,9 +32,12 @@
<small class="form-text text-muted">現在は変更できません。</small>
</div>
<div class="from-group mt-3">
<label for="name">メールアドレス</label>
<input id="name" name="name" type="text" class="form-control" value="{{ Auth::user()->email }}" disabled>
<small class="form-text text-muted">現在は変更できません。</small>
<label for="email">メールアドレス</label>
<input id="email" name="email" type="email" class="form-control {{ $errors->has('email') ? ' is-invalid' : '' }}" value="{{ old('email') ?? Auth::user()->email }}">
@if ($errors->has('email'))
<div class="invalid-feedback">{{ $errors->first('email') }}</div>
@endif
</div>
<div class="form-group mt-3">
<label for="bio">自己紹介</label>