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/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/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'); + }); + } +} 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 2afcd29..676764f 100644 --- a/resources/views/components/profile.blade.php +++ b/resources/views/components/profile.blade.php @@ -1,36 +1,38 @@
-
- -
-

- {{ $user->display_name }} -

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

{{ $currentSession }}経過

-

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

- @else -

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

-

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

+ +

+ {{ $user->display_name }} +

+
+ @{{ $user->name }} + @if ($user->is_protected) + @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 }}回

+ {{-- Bio --}} + @if (!empty($user->bio)) +

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

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

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

@endif
-
\ No newline at end of file + + +@if (!$user->is_protected || $user->isMe()) +
+
+ @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 +
+
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 +