メールアドレスを変更可能にする
This commit is contained in:
parent
2c1976fd2b
commit
66f4c45f5c
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class SettingController extends Controller
|
class SettingController extends Controller
|
||||||
{
|
{
|
||||||
@ -18,10 +19,18 @@ class SettingController extends Controller
|
|||||||
$inputs = $request->all();
|
$inputs = $request->all();
|
||||||
$validator = Validator::make($inputs, [
|
$validator = Validator::make($inputs, [
|
||||||
'display_name' => 'required|string|max:20',
|
'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',
|
'bio' => 'nullable|string|max:160',
|
||||||
'url' => 'nullable|url|max:2000'
|
'url' => 'nullable|url|max:2000'
|
||||||
], [], [
|
], [], [
|
||||||
'display_name' => '名前',
|
'display_name' => '名前',
|
||||||
|
'email' => 'メールアドレス',
|
||||||
'bio' => '自己紹介',
|
'bio' => '自己紹介',
|
||||||
'url' => 'URL'
|
'url' => 'URL'
|
||||||
]);
|
]);
|
||||||
@ -32,6 +41,7 @@ class SettingController extends Controller
|
|||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$user->display_name = $inputs['display_name'];
|
$user->display_name = $inputs['display_name'];
|
||||||
|
$user->email = $inputs['email'];
|
||||||
$user->bio = $inputs['bio'] ?? '';
|
$user->bio = $inputs['bio'] ?? '';
|
||||||
$user->url = $inputs['url'] ?? '';
|
$user->url = $inputs['url'] ?? '';
|
||||||
$user->save();
|
$user->save();
|
||||||
|
@ -32,9 +32,12 @@
|
|||||||
<small class="form-text text-muted">現在は変更できません。</small>
|
<small class="form-text text-muted">現在は変更できません。</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="from-group mt-3">
|
<div class="from-group mt-3">
|
||||||
<label for="name">メールアドレス</label>
|
<label for="email">メールアドレス</label>
|
||||||
<input id="name" name="name" type="text" class="form-control" value="{{ Auth::user()->email }}" disabled>
|
<input id="email" name="email" type="email" class="form-control {{ $errors->has('email') ? ' is-invalid' : '' }}" value="{{ old('email') ?? Auth::user()->email }}">
|
||||||
<small class="form-text text-muted">現在は変更できません。</small>
|
|
||||||
|
@if ($errors->has('email'))
|
||||||
|
<div class="invalid-feedback">{{ $errors->first('email') }}</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group mt-3">
|
<div class="form-group mt-3">
|
||||||
<label for="bio">自己紹介</label>
|
<label for="bio">自己紹介</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user