69 lines
1.5 KiB
PHP
69 lines
1.5 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
|
|
/**
|
|
* APP 用户模型(小程序端:门店 / 供应商用户)
|
|
*/
|
|
class UserModel extends Authenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
/** 状态:停用 */
|
|
public const int STATUS_DISABLED = 0;
|
|
/** 状态:正常 */
|
|
public const int STATUS_NORMAL = 1;
|
|
|
|
protected $table = 'user';
|
|
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'username',
|
|
'email',
|
|
'password',
|
|
'nickname',
|
|
'openid',
|
|
'unionid',
|
|
'phone',
|
|
'avatar',
|
|
'store_id',
|
|
'status',
|
|
'last_login_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime:Y-m-d H:i:s',
|
|
'last_login_at' => 'datetime:Y-m-d H:i:s',
|
|
'created_at' => 'datetime:Y-m-d H:i:s',
|
|
'store_id' => 'integer',
|
|
'status' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 关联门店
|
|
*/
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreModel::class, 'store_id', 'id');
|
|
}
|
|
/**
|
|
* 用户通知
|
|
*/
|
|
public function notices(): HasMany
|
|
{
|
|
return $this->hasMany(NoticeModel::class, 'user_id', 'id');
|
|
}
|
|
}
|