プロフィール設定の実装

This commit is contained in:
shibafu 2019-01-19 00:39:57 +09:00
parent 5d256519c6
commit 85cc865545
2 changed files with 23 additions and 3 deletions

View File

@ -13,9 +13,24 @@ class SettingController extends Controller
return view('setting.profile'); return view('setting.profile');
} }
public function updateProfile() public function updateProfile(Request $request)
{ {
abort(501); $inputs = $request->all();
$validator = Validator::make($inputs, [
'display_name' => 'required|string|max:20'
], [], [
'display_name' => '名前'
]);
if ($validator->fails()) {
return redirect()->route('setting')->withErrors($validator)->withInput();
}
$user = Auth::user();
$user->display_name = $inputs['display_name'];
$user->save();
return redirect()->route('setting')->with('status', 'プロフィールを更新しました。');
} }
public function updatePrivacy(Request $request) public function updatePrivacy(Request $request)

View File

@ -9,7 +9,12 @@
{{ csrf_field() }} {{ csrf_field() }}
<div class="from-group"> <div class="from-group">
<label for="display_name">名前</label> <label for="display_name">名前</label>
<input id="display_name" name="display_name" type="text" class="form-control" value="{{ old('display_name') ?? Auth::user()->display_name }}"> <input id="display_name" name="display_name" type="text" class="form-control {{ $errors->has('display_name') ? ' is-invalid' : '' }}"
value="{{ old('display_name') ?? Auth::user()->display_name }}" maxlength="20" autocomplete="off">
@if ($errors->has('display_name'))
<div class="invalid-feedback">{{ $errors->first('display_name') }}</div>
@endif
</div> </div>
<div class="from-group mt-2"> <div class="from-group mt-2">
<label for="name">ユーザー名</label> <label for="name">ユーザー名</label>