<?php

namespace app\model;

use app\model\Admin as AdminModel;
use think\Model;
use think\model\concern\SoftDelete;

class Admin extends Model
{
    //添加后缀需要设置模型名称
    protected $name = 'admin';

    //设置主键
    protected $pk = 'id';

    use SoftDelete;
    protected $deleteTime = 'delete_time';

//    public function role(){
//        return $this->belongsToMany(Role::class,Access::class,'role_id','admin_id');
//    }

    public function searchUsernameAttr($query, $value)
    {
        return $value ? $query->where('username', 'like', '%'.$value.'%') : '';
    }

    public function searchNicknameAttr($query, $value)
    {
        return $value ? $query->where('Nickname', 'like', '%'.$value.'%') : '';
    }

    public function searchEmailAttr($query, $value)
    {
        return $value ? $query->where('email', 'like', '%'.$value.'%') : '';
    }

    public function searchPhoneAttr($query, $value)
    {
        return $value ? $query->where('phone', 'like', '%'.$value.'%') : '';
    }


}