<?php

declare(strict_types=1);

namespace App\Model;



use Hyperf\Snowflake\Concern\Snowflake;

/**
 * @property int $manual_id 主键id
 * @property int $app_type 应用程序类型（1:小程序 2:app）
 * @property int $client_type 类型（1:患者端 2:医生端 3:药师端）
 * @property string $status 状态（0:删除 1:正常 2:禁用)
 * @property string $sort 排序值（越大排序越靠前）
 * @property string $title 标题
 * @property string $content 内容
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class OperationManual extends Model
{
    use Snowflake;

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

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['manual_id', 'app_type', 'client_type', 'status', 'sort', 'title', 'content', 'created_at', 'updated_at'];

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

    protected string $primaryKey = "manual_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 object|null
     */
    public static function getList(array $params, array $fields = ['*']): object|null
    {
        return self::where($params)->orderBy('sort','desc')->get($fields);
    }
}
