2017-08-27 04:44:53 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
2019-01-15 00:05:01 +09:00
|
|
|
use Illuminate\Notifications\Notifiable;
|
2017-11-05 22:29:09 +09:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2017-08-27 04:44:53 +09:00
|
|
|
|
|
|
|
class User extends Authenticatable
|
|
|
|
{
|
|
|
|
use Notifiable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'name', 'email', 'password',
|
|
|
|
'is_protected', 'accept_analytics',
|
|
|
|
'display_name', 'description',
|
|
|
|
'twitter_id', 'twitter_name',
|
2019-04-09 22:47:18 +09:00
|
|
|
'private_likes',
|
2017-08-27 04:44:53 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be hidden for arrays.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $hidden = [
|
|
|
|
'password', 'remember_token',
|
|
|
|
];
|
2017-10-23 00:03:24 +09:00
|
|
|
|
2020-05-23 21:34:49 +09:00
|
|
|
/**
|
|
|
|
* The attributes that should be cast to native types.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $casts = [
|
|
|
|
// 'email_verified_at' => 'datetime',
|
|
|
|
];
|
|
|
|
|
2017-10-23 00:03:24 +09:00
|
|
|
/**
|
|
|
|
* このユーザのメールアドレスから、Gravatarの画像URLを生成します。
|
|
|
|
* @param int $size 画像サイズ
|
|
|
|
* @return string Gravatar 画像URL
|
|
|
|
*/
|
2019-01-15 00:05:01 +09:00
|
|
|
public function getProfileImageUrl($size = 30): string
|
2017-11-05 22:29:09 +09:00
|
|
|
{
|
2017-10-23 00:03:24 +09:00
|
|
|
$hash = md5(strtolower(trim($this->email)));
|
2019-01-15 00:05:01 +09:00
|
|
|
|
2019-06-27 13:32:20 +09:00
|
|
|
return '//www.gravatar.com/avatar/' . $hash . '?s=' . $size . '&d=retro';
|
2017-10-23 00:03:24 +09:00
|
|
|
}
|
2017-11-05 22:29:09 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* このユーザがログイン中のユーザ本人であるかをチェックします。
|
|
|
|
* @return bool 本人かどうか
|
|
|
|
*/
|
|
|
|
public function isMe()
|
|
|
|
{
|
|
|
|
return Auth::check() && $this->id === Auth::user()->id;
|
|
|
|
}
|
2019-04-05 23:10:26 +09:00
|
|
|
|
2019-09-12 00:54:36 +09:00
|
|
|
public function ejaculations()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Ejaculation::class);
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:10:26 +09:00
|
|
|
public function likes()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Like::class);
|
|
|
|
}
|
2020-08-30 13:57:02 +09:00
|
|
|
|
|
|
|
public function checkinWebhooks()
|
|
|
|
{
|
|
|
|
return $this->hasMany(CheckinWebhook::class);
|
|
|
|
}
|
2017-08-27 04:44:53 +09:00
|
|
|
}
|