<?php

namespace app\admin\model;

use support\Db;
use support\Model;

/**
 * 医疗产品属性设置
 * Class Users
 * @package app\admin\model
 */
class MedicalCareProductAttrValue extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'medical_care_product_attr_value';

    public $timestamps = false;

    /**
     * Notes:获取产品列表
     * @param string $keywords
     * @param int $page
     * @param int $limit
     * @return array
     * User: QJF
     * Date: 2022/9/26
     */
    public static function getProductAttrList(int $page, int $limit,$keywords)
    {
        $list = static::select('*')
            ->orderBy('attr_create_time','DESC')
            ->forPage($page, $limit)
            ->get();

        $count = static::when($keywords != '', function ($query) use ($keywords){
            $query->where('product_name', 'like', '%' . $keywords . '%');
        })->count();
        return [$list, $count];
    }
}
