Files
crm-server/app/model/User.php
T

53 lines
1.2 KiB
PHP
Raw Normal View History

2025-03-14 14:27:33 +08:00
<?php
namespace app\model;
use support\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'user';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
2025-03-17 18:01:53 +08:00
// 指定日期字段存储格式为时间戳
protected $dateFormat = 'U';
//设置黑名单
2025-04-02 15:17:13 +08:00
protected $guarded = ['created_at','updated_at'];
2025-03-17 18:01:53 +08:00
protected $casts = [
// 'updated_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
// 'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
'updated_at' => 'timestamp', // 指定序列化格式
'created_at' => 'timestamp', // 指定序列化格式
];
2025-03-14 14:27:33 +08:00
public static function getUser($userId)
{
$user = User::first()->select(['id','name','sex','role','avatar','email','password'])
->where('status',0)
->toArray();
return $user;
}
}