<?php

namespace App\Models\User;

use App\Models\Base;
use Illuminate\Support\Facades\DB;


class User extends Base
{
    const ROLE_MANAGER = 0;//超级管理员
    const TYPE_ONE = 1;

    const STATUS_ZERO = 0;

    protected $table = 'gl_project_user';
    //自动维护create_at创建时间 updated_at修改时间
    public $timestamps = true;

    const LOGIN_AUTO_SOURCE = 1;//自动登录
    const LOGIN_PASSWORD_SOURCE = 2;//账号密码登录
    const LOGIN_OTHER_SOURCE = 3;//其他平台切入
    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
    ];

    /**
     * @remark :获取名称
     * @name   :getName
     * @author :lyh
     * @method :post
     * @time   :2023/8/8 15:00
     */
    public function getName($id){
        $name = '';
        if(!empty($id)){
            $info = $this->read(['id'=>$id],['id','name']);
            if($info === false){
                return '用户不存在';
            }
            $name = $info['name'];
        }
        return $name;
    }
}