Merge pull request #59 from shikorism/feature/settings
ユーザー設定画面 (プロフィール, プライバシー関連)
This commit is contained in:
		
							
								
								
									
										58
									
								
								app/Http/Controllers/SettingController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								app/Http/Controllers/SettingController.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,58 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace App\Http\Controllers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Http\Request;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Auth;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Validator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SettingController extends Controller
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public function profile()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return view('setting.profile');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function updateProfile(Request $request)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $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 privacy()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return view('setting.privacy');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function updatePrivacy(Request $request)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $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.privacy')->with('status', 'プライバシー設定を更新しました。');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ( ◠‿◠ )☛ここに気づいたか・・・消えてもらう ▂▅▇█▓▒░(’ω’)░▒▓█▇▅▂うわあああああああ
 | 
				
			||||||
 | 
					//    public function password()
 | 
				
			||||||
 | 
					//    {
 | 
				
			||||||
 | 
					//        abort(501);
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -72,7 +72,7 @@
 | 
				
			|||||||
                                </p>
 | 
					                                </p>
 | 
				
			||||||
                            </a>
 | 
					                            </a>
 | 
				
			||||||
                            <div class="dropdown-divider"></div>
 | 
					                            <div class="dropdown-divider"></div>
 | 
				
			||||||
                            {{--<a href="#" class="dropdown-item">設定</a>--}}
 | 
					                            <a href="{{ route('setting') }}" class="dropdown-item">設定</a>
 | 
				
			||||||
                            <a href="{{ route('logout') }}" class="dropdown-item" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">ログアウト</a>
 | 
					                            <a href="{{ route('logout') }}" class="dropdown-item" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">ログアウト</a>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </li>
 | 
					                    </li>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										22
									
								
								resources/views/setting/base.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/views/setting/base.blade.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					@extends('layouts.base')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@section('content')
 | 
				
			||||||
 | 
					    <div class="container">
 | 
				
			||||||
 | 
					        <div class="row">
 | 
				
			||||||
 | 
					            <div class="col-lg-4">
 | 
				
			||||||
 | 
					                <div class="list-group">
 | 
				
			||||||
 | 
					                    <div class="list-group-item disabled font-weight-bold">設定</div>
 | 
				
			||||||
 | 
					                    <a class="list-group-item list-group-item-action {{ Route::currentRouteName() === 'setting' ? 'active' : '' }}"
 | 
				
			||||||
 | 
					                       href="{{ route('setting') }}"><span class="oi oi-person mr-1"></span> プロフィール</a>
 | 
				
			||||||
 | 
					                    <a class="list-group-item list-group-item-action {{ Route::currentRouteName() === 'setting.privacy' ? 'active' : '' }}"
 | 
				
			||||||
 | 
					                       href="{{ route('setting.privacy') }}"><span class="oi oi-shield mr-1"></span> プライバシー</a>
 | 
				
			||||||
 | 
					                    {{--<a class="list-group-item list-group-item-action {{ Route::currentRouteName() === 'setting.password' ? 'active' : '' }}"
 | 
				
			||||||
 | 
					                       href="{{ route('setting.password') }}"><span class="oi oi-key mr-1"></span> パスワード</a>--}}
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					            <div class="tab-content col-lg-8">
 | 
				
			||||||
 | 
					                @yield('tab-content')
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					@endsection
 | 
				
			||||||
							
								
								
									
										33
									
								
								resources/views/setting/privacy.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								resources/views/setting/privacy.blade.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					@extends('setting.base')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@section('title', 'プライバシー設定')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@section('tab-content')
 | 
				
			||||||
 | 
					    <h3>プライバシー</h3>
 | 
				
			||||||
 | 
					    <hr>
 | 
				
			||||||
 | 
					    <form action="{{ route('setting.privacy.update') }}" method="post">
 | 
				
			||||||
 | 
					        {{ 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') ?? 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') ?? Auth::user()->accept_analytics ) ? 'checked' : '' }}>
 | 
				
			||||||
 | 
					                <label class="custom-control-label" for="accept-analytics">匿名での統計にチェックインデータを利用することに同意します</label>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <button type="submit" class="btn btn-primary mt-2">更新</button>
 | 
				
			||||||
 | 
					    </form>
 | 
				
			||||||
 | 
					@endsection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@push('script')
 | 
				
			||||||
 | 
					    <script>
 | 
				
			||||||
 | 
					        $('#protected').on('change', function () {
 | 
				
			||||||
 | 
					            if (!$(this).prop('checked')) {
 | 
				
			||||||
 | 
					                alert('チェックイン履歴を公開に切り替えると、個別に非公開設定されているものを除いた全てのチェックインが誰でも閲覧できるようになります。\nご注意ください。');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    </script>
 | 
				
			||||||
 | 
					@endpush
 | 
				
			||||||
							
								
								
									
										32
									
								
								resources/views/setting/profile.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								resources/views/setting/profile.blade.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					@extends('setting.base')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@section('title', 'プロフィール設定')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@section('tab-content')
 | 
				
			||||||
 | 
					    <h3>プロフィール</h3>
 | 
				
			||||||
 | 
					    <hr>
 | 
				
			||||||
 | 
					    <form action="{{ route('setting.profile.update') }}" method="post">
 | 
				
			||||||
 | 
					        {{ csrf_field() }}
 | 
				
			||||||
 | 
					        <div class="from-group">
 | 
				
			||||||
 | 
					            <label for="display_name">名前</label>
 | 
				
			||||||
 | 
					            <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 class="from-group mt-2">
 | 
				
			||||||
 | 
					            <label for="name">ユーザー名</label>
 | 
				
			||||||
 | 
					            <div class="input-group">
 | 
				
			||||||
 | 
					                <div class="input-group-prepend">
 | 
				
			||||||
 | 
					                    <div class="input-group-text">@</div>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					                <input id="name" name="name" type="text" class="form-control" value="{{ Auth::user()->name }}" disabled>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					            <small class="form-text text-muted">現在は変更できません。</small>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <button type="submit" class="btn btn-primary mt-4">更新</button>
 | 
				
			||||||
 | 
					    </form>
 | 
				
			||||||
 | 
					@endsection
 | 
				
			||||||
@@ -29,6 +29,13 @@ Route::middleware('auth')->group(function () {
 | 
				
			|||||||
    Route::get('/checkin/{id}/edit', 'EjaculationController@edit')->name('checkin.edit');
 | 
					    Route::get('/checkin/{id}/edit', 'EjaculationController@edit')->name('checkin.edit');
 | 
				
			||||||
    Route::put('/checkin/{id}', 'EjaculationController@update')->name('checkin.update');
 | 
					    Route::put('/checkin/{id}', 'EjaculationController@update')->name('checkin.update');
 | 
				
			||||||
    Route::delete('/checkin/{id}', 'EjaculationController@destroy')->name('checkin.destroy');
 | 
					    Route::delete('/checkin/{id}', 'EjaculationController@destroy')->name('checkin.destroy');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Route::redirect('/setting', '/setting/profile', 301);
 | 
				
			||||||
 | 
					    Route::get('/setting/profile', 'SettingController@profile')->name('setting');
 | 
				
			||||||
 | 
					    Route::post('/setting/profile', 'SettingController@updateProfile')->name('setting.profile.update');
 | 
				
			||||||
 | 
					    Route::get('/setting/privacy', 'SettingController@privacy')->name('setting.privacy');
 | 
				
			||||||
 | 
					    Route::post('/setting/privacy', 'SettingController@updatePrivacy')->name('setting.privacy.update');
 | 
				
			||||||
 | 
					//    Route::get('/setting/password', 'SettingController@password')->name('setting.password');
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Route::get('/info', 'InfoController@index')->name('info');
 | 
					Route::get('/info', 'InfoController@index')->name('info');
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user