2018-10-19 00:56:29 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2019-01-19 00:29:36 +09:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
2018-10-19 00:56:29 +09:00
|
|
|
|
|
|
|
class SettingController extends Controller
|
|
|
|
{
|
|
|
|
public function profile()
|
|
|
|
{
|
|
|
|
return view('setting.profile');
|
|
|
|
}
|
|
|
|
|
2019-01-19 00:39:57 +09:00
|
|
|
public function updateProfile(Request $request)
|
2018-12-30 23:19:52 +09:00
|
|
|
{
|
2019-01-19 00:39:57 +09:00
|
|
|
$inputs = $request->all();
|
|
|
|
$validator = Validator::make($inputs, [
|
2019-02-07 00:27:43 +09:00
|
|
|
'display_name' => 'required|string|max:20',
|
|
|
|
'bio' => 'nullable|string|max:160',
|
|
|
|
'url' => 'nullable|url|max:2000'
|
2019-01-19 00:39:57 +09:00
|
|
|
], [], [
|
2019-02-07 00:27:43 +09:00
|
|
|
'display_name' => '名前',
|
|
|
|
'bio' => '自己紹介',
|
|
|
|
'url' => 'URL'
|
2019-01-19 00:39:57 +09:00
|
|
|
]);
|
|
|
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
return redirect()->route('setting')->withErrors($validator)->withInput();
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = Auth::user();
|
|
|
|
$user->display_name = $inputs['display_name'];
|
2019-02-07 00:27:43 +09:00
|
|
|
$user->bio = $inputs['bio'] ?? '';
|
|
|
|
$user->url = $inputs['url'] ?? '';
|
2019-01-19 00:39:57 +09:00
|
|
|
$user->save();
|
|
|
|
|
|
|
|
return redirect()->route('setting')->with('status', 'プロフィールを更新しました。');
|
2018-12-30 23:19:52 +09:00
|
|
|
}
|
|
|
|
|
2019-01-19 01:17:56 +09:00
|
|
|
public function privacy()
|
|
|
|
{
|
|
|
|
return view('setting.privacy');
|
|
|
|
}
|
|
|
|
|
2019-01-19 00:29:36 +09:00
|
|
|
public function updatePrivacy(Request $request)
|
2018-12-30 23:19:52 +09:00
|
|
|
{
|
2019-04-09 22:59:10 +09:00
|
|
|
$inputs = $request->all(['is_protected', 'accept_analytics', 'private_likes']);
|
2019-01-19 00:29:36 +09:00
|
|
|
|
|
|
|
$user = Auth::user();
|
|
|
|
$user->is_protected = $inputs['is_protected'] ?? false;
|
|
|
|
$user->accept_analytics = $inputs['accept_analytics'] ?? false;
|
2019-04-09 22:59:10 +09:00
|
|
|
$user->private_likes = $inputs['private_likes'] ?? false;
|
2019-01-19 00:29:36 +09:00
|
|
|
$user->save();
|
|
|
|
|
2019-01-19 01:17:56 +09:00
|
|
|
return redirect()->route('setting.privacy')->with('status', 'プライバシー設定を更新しました。');
|
2018-12-30 23:19:52 +09:00
|
|
|
}
|
|
|
|
|
2019-01-19 00:13:34 +09:00
|
|
|
// ( ◠‿◠ )☛ここに気づいたか・・・消えてもらう ▂▅▇█▓▒░(’ω’)░▒▓█▇▅▂うわあああああああ
|
|
|
|
// public function password()
|
|
|
|
// {
|
|
|
|
// abort(501);
|
|
|
|
// }
|
2018-10-19 00:56:29 +09:00
|
|
|
}
|