| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Models;
- use DateTimeInterface;
- use Illuminate\Database\Eloquent\Model;
- /**
- * 系统员工表
- *
- * @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
- * @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
- * @method static \Illuminate\Database\Eloquent\Builder|User query()
- * @mixin \Eloquent
- */
- class User extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'users';
- /**
- * The primary key associated with the table.
- *
- * @var string
- */
- protected $primaryKey = 'id';
- /**
- * Indicates if the model should be timestamped.
- *
- * @var bool
- */
- public $timestamps = true;
- /**
- * 可以被批量赋值的属性。
- *
- * @var array
- */
- protected $fillable = ['id','name','phone','password','encrypt','api_token','roles_id','status','is_del'];
- private $statusEnum=[
- 1=>'正常',
- 2=>'关闭',
- ];
- /**
- * 为数组 / JSON 序列化准备日期。
- *
- * @param DateTimeInterface $date
- * @return string
- */
- protected function serializeDate(DateTimeInterface $date)
- {
- return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
- }
- /**
- * 序列化数据字典
- */
- function initializeModel(){
- if($this->{'status'}!==null){
- $this->{'status_str'}=empty($this->statusEnum[$this->{'status'}])?'无':$this->statusEnum[$this->{'status'}];
- }
- }
- }
|