プライバシー設定の更新を実装

This commit is contained in:
shibafu 2019-01-19 00:29:36 +09:00
parent 550d897561
commit 53b459740f
2 changed files with 15 additions and 6 deletions

View File

@ -3,6 +3,8 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
class SettingController extends Controller
{
@ -16,9 +18,16 @@ class SettingController extends Controller
abort(501);
}
public function updatePrivacy()
public function updatePrivacy(Request $request)
{
abort(501);
$inputs = $request->all(['is_protected', 'accept_analytics']);
$user = Auth::user();
$user->is_protected = $inputs['is_protected'] ?? false;
$user->accept_analytics = $inputs['accept_analytics'] ?? false;
$user->save();
return redirect()->route('setting')->with('status', 'プライバシー設定を更新しました。');
}
// ( ◠‿◠ )☛ここに気づいたか・・・消えてもらう ▂▅▇█▓▒░(’ω’)░▒▓█▇▅▂うわあああああああ

View File

@ -7,7 +7,7 @@
{{ csrf_field() }}
<div class="from-group">
<label for="display_name">名前</label>
<input id="display_name" name="display_name" type="text" class="form-control">
<input id="display_name" name="display_name" type="text" class="form-control" value="{{ old('display_name') ?? Auth::user()->display_name }}">
</div>
<div class="from-group mt-2">
<label for="name">ユーザー名</label>
@ -15,7 +15,7 @@
<div class="input-group-prepend">
<div class="input-group-text">@</div>
</div>
<input id="name" name="name" type="text" class="form-control" disabled>
<input id="name" name="name" type="text" class="form-control" value="{{ Auth::user()->name }}" disabled>
</div>
<small class="form-text text-muted">現在は変更できません。</small>
</div>
@ -29,11 +29,11 @@
{{ csrf_field() }}
<div class="form-group">
<div class="custom-control custom-checkbox mb-2">
<input id="protected" name="is_protected" class="custom-control-input" type="checkbox" {{ old('is_protected') ? 'checked' : '' }}>
<input id="protected" name="is_protected" class="custom-control-input" type="checkbox" {{ (old('is_protected') ?? Auth::user()->is_protected ) ? 'checked' : '' }}>
<label class="custom-control-label" for="protected">全てのチェックイン履歴を非公開にする</label>
</div>
<div class="custom-control custom-checkbox">
<input id="accept-analytics" name="accept_analytics" class="custom-control-input" type="checkbox" {{ old('accept_analytics') ? 'checked' : '' }}>
<input id="accept-analytics" name="accept_analytics" class="custom-control-input" type="checkbox" {{ (old('accept_analytics') ?? Auth::user()->accept_analytics ) ? 'checked' : '' }}>
<label class="custom-control-label" for="accept-analytics">匿名での統計にチェックインデータを利用することに同意します</label>
</div>
</div>