diff --git a/app/User.php b/app/User.php index ed4520f..94fcf46 100644 --- a/app/User.php +++ b/app/User.php @@ -4,6 +4,7 @@ namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Support\Facades\Auth; class User extends Authenticatable { @@ -35,8 +36,18 @@ class User extends Authenticatable * @param int $size 画像サイズ * @return string Gravatar 画像URL */ - public function getProfileImageUrl($size = 30) : string { + public function getProfileImageUrl($size = 30) : string + { $hash = md5(strtolower(trim($this->email))); return '//www.gravatar.com/avatar/' . $hash . '?s=' . $size; } + + /** + * このユーザがログイン中のユーザ本人であるかをチェックします。 + * @return bool 本人かどうか + */ + public function isMe() + { + return Auth::check() && $this->id === Auth::user()->id; + } } diff --git a/resources/views/ejaculation/show.blade.php b/resources/views/ejaculation/show.blade.php index fe86916..5e2567c 100644 --- a/resources/views/ejaculation/show.blade.php +++ b/resources/views/ejaculation/show.blade.php @@ -8,13 +8,13 @@ @endcomponent
- @if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) + @if ($user->is_protected && !$user->isMe())
このユーザはチェックイン履歴を公開していません。
- @elseif ($ejaculation->is_private && !(Auth::check() && $user->id === Auth::user()->id)) + @elseif ($ejaculation->is_private && !$user->isMe())
非公開チェックインのため、表示できません @@ -26,7 +26,7 @@
{{ $ejaculatedSpan ?? '精通' }} {{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ~ ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}
- @if (Auth::check() && $user->id === Auth::user()->id) + @if ($user->isMe())
diff --git a/resources/views/user/okazu.blade.php b/resources/views/user/okazu.blade.php index b0ef760..b1f135e 100644 --- a/resources/views/user/okazu.blade.php +++ b/resources/views/user/okazu.blade.php @@ -1,7 +1,7 @@ @extends('user.base') @section('tab-content') -@if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) +@if ($user->is_protected && !$user->isMe())

このユーザはチェックイン履歴を公開していません。

diff --git a/resources/views/user/profile.blade.php b/resources/views/user/profile.blade.php index 6df3dec..4b3209c 100644 --- a/resources/views/user/profile.blade.php +++ b/resources/views/user/profile.blade.php @@ -1,7 +1,7 @@ @extends('user.base') @section('tab-content') -@if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) +@if ($user->is_protected && !$user->isMe())

このユーザはチェックイン履歴を公開していません。

@@ -12,7 +12,7 @@
{{ $ejaculation->ejaculated_span ?? '精通' }} {{ $ejaculation->before_date }}{{ !empty($ejaculation->before_date) ? ' ~ ' : '' }}{{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}
- @if (Auth::check() && $user->id === Auth::user()->id) + @if ($user->isMe())
diff --git a/resources/views/user/stats.blade.php b/resources/views/user/stats.blade.php index b0ef760..b1f135e 100644 --- a/resources/views/user/stats.blade.php +++ b/resources/views/user/stats.blade.php @@ -1,7 +1,7 @@ @extends('user.base') @section('tab-content') -@if ($user->is_protected && !(Auth::check() && $user->id === Auth::user()->id)) +@if ($user->is_protected && !$user->isMe())

このユーザはチェックイン履歴を公開していません。