<?php

namespace App\Modules\CpUser\Models;

use Illuminate\Database\Eloquent\Model;

class CpUser extends Model
{
    protected  $table = 'cp_users';
    protected  $fillable = ['username','password','id_enabled','created_at','updated_at'];

    /**
     * 获取用户
     */
    public static function getCpUser($username) {
        return self::where(['username'=>$username])->first();
    }
    
    /**
     * 获取用户by id
     */
    public static function getCpUserById($id) {
    	return self::where(['id'=>$id])->first();
    }
    
    //修改密码
    static function modifyPassword($username, $password)
    {
        return self::where('username', $username)->update(compact('password'));
    }
}