ユーザの本人判定をModelに逃した
This commit is contained in:
13
app/User.php
13
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user