generated from liutk/owl-admin-base
43 lines
998 B
PHP
43 lines
998 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use EloquentFilter\Filterable;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable, Filterable;
|
|
|
|
protected $appends = ['last_ip'];
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'nick_name',
|
|
'avatar',
|
|
'phone',
|
|
'mini_openid',
|
|
'union_id',
|
|
'last_login_at',
|
|
'last_login_ip',
|
|
'bind_phone_at'
|
|
];
|
|
|
|
//ip
|
|
protected function lastIp():Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn($value) => $this->last_login_ip ? long2ip($this->last_login_ip) : "未知",
|
|
);
|
|
}
|
|
|
|
}
|