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 @@ +
{{ $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 @@{{ $currentSession }}経過
-({{ $latestEjaculation->ejaculated_date->format('Y/m/d H:i') }} にリセット)
- @else -計測がまだ始まっていません
-(一度チェックインすると始まります)
+ +平均記録: {{ 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)) + @endif