From 4346e1a701ae9eb057091c3aafcbdef068b06bfc Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 7 Feb 2019 00:10:43 +0900 Subject: [PATCH 1/4] =?UTF-8?q?users=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB?= =?UTF-8?q?=E3=81=AB=E8=87=AA=E5=B7=B1=E7=B4=B9=E4=BB=8B=E3=81=A8URL?= =?UTF-8?q?=E3=81=AE=E5=88=97=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._02_06_235832_add_bio_and_url_to_users.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/migrations/2019_02_06_235832_add_bio_and_url_to_users.php diff --git a/database/migrations/2019_02_06_235832_add_bio_and_url_to_users.php b/database/migrations/2019_02_06_235832_add_bio_and_url_to_users.php new file mode 100644 index 0000000..d8988d4 --- /dev/null +++ b/database/migrations/2019_02_06_235832_add_bio_and_url_to_users.php @@ -0,0 +1,34 @@ +string('bio', 160)->default(''); + $table->text('url')->default(''); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('bio'); + $table->dropColumn('url'); + }); + } +} From 82af423c570897f850faff4a427835415288b045 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 7 Feb 2019 00:10:58 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=95=E3=82=A3?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E6=AC=84=E3=81=AB=E8=87=AA=E5=B7=B1=E7=B4=B9?= =?UTF-8?q?=E4=BB=8B=E3=81=A8URL=E3=82=92=E6=8E=B2=E8=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/components/profile.blade.php | 27 +++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/resources/views/components/profile.blade.php b/resources/views/components/profile.blade.php index 2afcd29..42d7a4a 100644 --- a/resources/views/components/profile.blade.php +++ b/resources/views/components/profile.blade.php @@ -15,8 +15,27 @@ - @if (!$user->is_protected || $user->isMe()) -
現在のセッション
+ {{-- Bio --}} + @if (!empty($user->bio)) +

+ {!! Formatter::linkify(nl2br(e($user->bio))) !!} +

+ @endif + + {{-- URL --}} + @if (!empty($user->url)) +

+ + {{ preg_replace('~\Ahttps?://~', '', $user->url) }} +

+ @endif + + + +@if (!$user->is_protected || $user->isMe()) +
+
+
現在のセッション
@if (isset($currentSession))

{{ $currentSession }}経過

({{ $latestEjaculation->ejaculated_date->format('Y/m/d H:i') }} にリセット)

@@ -31,6 +50,6 @@

最短記録: {{ Formatter::formatInterval($summary[0]->shortest) }}

合計時間: {{ Formatter::formatInterval($summary[0]->total_times) }}

通算回数: {{ $summary[0]->total_checkins }}回

- @endif +
- \ No newline at end of file +@endif From 41e810c788dfbbc39b7e7fc6824286e48c3c1b35 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 7 Feb 2019 00:27:43 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=95=E3=82=A3?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E8=A8=AD=E5=AE=9A=E7=94=BB=E9=9D=A2=E3=81=AB?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=B4=B9=E4=BB=8B=E3=81=A8URL=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/SettingController.php | 10 ++++++++-- resources/views/setting/profile.blade.php | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.php index 1f812e3..136f055 100644 --- a/app/Http/Controllers/SettingController.php +++ b/app/Http/Controllers/SettingController.php @@ -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', 'プロフィールを更新しました。'); diff --git a/resources/views/setting/profile.blade.php b/resources/views/setting/profile.blade.php index 4bbe86a..92df931 100644 --- a/resources/views/setting/profile.blade.php +++ b/resources/views/setting/profile.blade.php @@ -16,7 +16,7 @@
{{ $errors->first('display_name') }}
@endif -
+
@@ -26,6 +26,24 @@
現在は変更できません。
+
+ + + 最大 160 文字 + + @if ($errors->has('bio')) +
{{ $errors->first('bio') }}
+ @endif +
+
+ + + + @if ($errors->has('url')) +
{{ $errors->first('url') }}
+ @endif +
From 1f7723614de7c5b678080411fcd06d9e7d91a24e Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 7 Feb 2019 00:52:03 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E3=83=9B=E3=83=BC=E3=83=A0=E3=81=A7?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E8=87=AA=E8=BA=AB=E3=81=AE?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=81=A8=E3=80=81=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=A7=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=83=97=E3=83=AD=E3=83=95=E3=82=A3=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E6=83=85=E5=A0=B1=E3=82=92=E5=88=A5=E3=81=AE=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eComposer.php => ProfileStatsComposer.php} | 2 +- app/Providers/ViewComposerServiceProvider.php | 4 +- .../views/components/profile-stats.blade.php | 15 +++++++ resources/views/components/profile.blade.php | 41 ++++++------------- resources/views/home.blade.php | 22 +++++++++- 5 files changed, 50 insertions(+), 34 deletions(-) rename app/Http/ViewComposers/{ProfileComposer.php => ProfileStatsComposer.php} (98%) create mode 100644 resources/views/components/profile-stats.blade.php diff --git a/app/Http/ViewComposers/ProfileComposer.php b/app/Http/ViewComposers/ProfileStatsComposer.php similarity index 98% rename from app/Http/ViewComposers/ProfileComposer.php rename to app/Http/ViewComposers/ProfileStatsComposer.php index cbb9a85..6f93ded 100644 --- a/app/Http/ViewComposers/ProfileComposer.php +++ b/app/Http/ViewComposers/ProfileStatsComposer.php @@ -7,7 +7,7 @@ use Carbon\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\View\View; -class ProfileComposer +class ProfileStatsComposer { public function __construct() { diff --git a/app/Providers/ViewComposerServiceProvider.php b/app/Providers/ViewComposerServiceProvider.php index bb4f062..70bf1fd 100644 --- a/app/Providers/ViewComposerServiceProvider.php +++ b/app/Providers/ViewComposerServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use App\Http\ViewComposers\ProfileComposer; +use App\Http\ViewComposers\ProfileStatsComposer; use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; @@ -15,7 +15,7 @@ class ViewComposerServiceProvider extends ServiceProvider */ public function boot() { - View::composer('components.profile', ProfileComposer::class); + View::composer('components.profile-stats', ProfileStatsComposer::class); } /** diff --git a/resources/views/components/profile-stats.blade.php b/resources/views/components/profile-stats.blade.php new file mode 100644 index 0000000..4502525 --- /dev/null +++ b/resources/views/components/profile-stats.blade.php @@ -0,0 +1,15 @@ +
現在のセッション
+@if (isset($currentSession)) +

{{ $currentSession }}経過

+

({{ $latestEjaculation->ejaculated_date->format('Y/m/d H:i') }} にリセット)

+@else +

計測がまだ始まっていません

+

(一度チェックインすると始まります)

+@endif + +
概況
+

平均記録: {{ Formatter::formatInterval($summary[0]->average) }}

+

最長記録: {{ Formatter::formatInterval($summary[0]->longest) }}

+

最短記録: {{ Formatter::formatInterval($summary[0]->shortest) }}

+

合計時間: {{ Formatter::formatInterval($summary[0]->total_times) }}

+

通算回数: {{ $summary[0]->total_checkins }}回

\ No newline at end of file diff --git a/resources/views/components/profile.blade.php b/resources/views/components/profile.blade.php index 42d7a4a..676764f 100644 --- a/resources/views/components/profile.blade.php +++ b/resources/views/components/profile.blade.php @@ -1,19 +1,15 @@
-
- -
-

- {{ $user->display_name }} -

-
- @{{ $user->name }} - @if ($user->is_protected) - - @endif -
-
-
+ +

+ {{ $user->display_name }} +

+
+ @{{ $user->name }} + @if ($user->is_protected) + + @endif +
{{-- Bio --}} @if (!empty($user->bio)) @@ -35,21 +31,8 @@ @if (!$user->is_protected || $user->isMe())
-
現在のセッション
- @if (isset($currentSession)) -

{{ $currentSession }}経過

-

({{ $latestEjaculation->ejaculated_date->format('Y/m/d H:i') }} にリセット)

- @else -

計測がまだ始まっていません

-

(一度チェックインすると始まります)

- @endif - -
概況
-

平均記録: {{ Formatter::formatInterval($summary[0]->average) }}

-

最長記録: {{ Formatter::formatInterval($summary[0]->longest) }}

-

最短記録: {{ Formatter::formatInterval($summary[0]->shortest) }}

-

合計時間: {{ Formatter::formatInterval($summary[0]->total_times) }}

-

通算回数: {{ $summary[0]->total_checkins }}回

+ @component('components.profile-stats', ['user' => $user]) + @endcomponent
@endif diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index cdb81cb..aa9d64f 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -7,8 +7,26 @@
- @component('components.profile', ['user' => Auth::user()]) - @endcomponent +
+
+
+ +
+
+ {{ Auth::user()->display_name }} +
+
+ @{{ Auth::user()->name }} + @if (Auth::user()->is_protected) + + @endif +
+
+
+ @component('components.profile-stats', ['user' => Auth::user()]) + @endcomponent +
+