プロフィール設定画面に自己紹介とURLを追加
This commit is contained in:
parent
82af423c57
commit
41e810c788
@ -17,9 +17,13 @@ class SettingController extends Controller
|
||||
{
|
||||
$inputs = $request->all();
|
||||
$validator = Validator::make($inputs, [
|
||||
'display_name' => 'required|string|max:20'
|
||||
'display_name' => 'required|string|max:20',
|
||||
'bio' => 'nullable|string|max:160',
|
||||
'url' => 'nullable|url|max:2000'
|
||||
], [], [
|
||||
'display_name' => '名前'
|
||||
'display_name' => '名前',
|
||||
'bio' => '自己紹介',
|
||||
'url' => 'URL'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
@ -28,6 +32,8 @@ class SettingController extends Controller
|
||||
|
||||
$user = Auth::user();
|
||||
$user->display_name = $inputs['display_name'];
|
||||
$user->bio = $inputs['bio'] ?? '';
|
||||
$user->url = $inputs['url'] ?? '';
|
||||
$user->save();
|
||||
|
||||
return redirect()->route('setting')->with('status', 'プロフィールを更新しました。');
|
||||
|
@ -16,7 +16,7 @@
|
||||
<div class="invalid-feedback">{{ $errors->first('display_name') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="from-group mt-2">
|
||||
<div class="from-group mt-3">
|
||||
<label for="name">ユーザー名</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
@ -26,6 +26,24 @@
|
||||
</div>
|
||||
<small class="form-text text-muted">現在は変更できません。</small>
|
||||
</div>
|
||||
<div class="form-group mt-3">
|
||||
<label for="bio">自己紹介</label>
|
||||
<textarea id="bio" name="bio" rows="3" class="form-control {{ $errors->has('bio') ? ' is-invalid' : '' }}">{{ old('bio') ?? Auth::user()->bio }}</textarea>
|
||||
<small class="form-text text-muted">最大 160 文字</small>
|
||||
|
||||
@if ($errors->has('bio'))
|
||||
<div class="invalid-feedback">{{ $errors->first('bio') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group mt-3">
|
||||
<label for="url">URL</label>
|
||||
<input id="url" name="url" type="url" class="form-control {{ $errors->has('url') ? ' is-invalid' : '' }}"
|
||||
value="{{ old('url') ?? Auth::user()->url }}" autocomplete="off">
|
||||
|
||||
@if ($errors->has('url'))
|
||||
<div class="invalid-feedback">{{ $errors->first('url') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-4">更新</button>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user