<?php

namespace app\admin\model;

use support\Db;
use support\Model;

/**
 * 医疗产品
 * Class Users
 * @package app\admin\model
 */
class MedicalCarePostage extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'medical_care_postage';

    public $timestamps = false;

    /**
     * Notes:获取运费列表
     * @param string $keywords
     * @param int $page
     * @param int $limit
     * @return array
     * User: QJF
     * Date: 2022/9/28
     */
    public static function getPostagetList(int $page, int $limit,$keywords)
    {
        $list = static::select('*')
            ->when($keywords != '', function ($query) use ($keywords){
                $query->where('postage_name', 'like', '%' . $keywords . '%');
            })
            ->where('postage_is_delete',0)
            ->orderBy('postage_create_time','DESC')
            ->forPage($page, $limit)
            ->get();

        $count = static::when($keywords != '', function ($query) use ($keywords){
            $query->where('postage_name', 'like', '%' . $keywords . '%');
        })->where('postage_is_delete',0)->count();
        return [$list, $count];
    }
    public function getPostageCreateTimeAttribute($value)
    {
        return date('Y-m-d H:i:s', $value);
    }
    public function getPostageUpdateTimeAttribute($value)
    {
        return date('Y-m-d H:i:s', $value);
    }
}