<?php

declare(strict_types=1);

namespace App\Model;



use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;

/**
 * @property int $bank_id 主键id
 * @property string $bank_code 银行编码
 * @property string $bank_name 银行名称
 * @property string $bank_img_path 银行图片地址
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class BasicBank extends Model
{
    use Snowflake;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'basic_bank';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['bank_id', 'bank_code', 'bank_name', 'bank_img_path', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['bank_id' => 'string', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    protected string $primaryKey = "bank_id";

    /**
     * 获取信息-单条
     * @param array $params
     * @param array $fields
     * @return object|null
     */
    public static function getOne(array $params, array $fields = ['*']): object|null
    {
        return self::where($params)->first($fields);
    }

    /**
     * 获取信息-多条
     * @param array $params
     * @param array $fields
     * @return Collection|array
     */
    public static function getList(array $params, array $fields = ['*']): Collection|array
    {
        return self::where($params)->get($fields);
    }
}
