getStatusList(); return $list[$status] ?? ''; } /** * 根据名称获取供应商 */ public static function getByName($name) { return self::where('name', $name)->find(); } /** * 获取供应商选项列表 */ public static function getOptions() { return self::where('status', StatusEnum::ENABLED) ->order('weigh desc, id desc') ->field('id,name') ->select(); } protected static function init() { self::afterInsert(function ($row) { if (!$row['weigh']) { $pk = $row->getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); } }); } public function category() { return $this->belongsTo('app\common\model\supplier\Category', 'category_id', 'id'); } }