<?php

namespace app\common\model;

use think\Model;

/**
 * 分类模型
 */
class Usergangwei extends Model
{

    // 表名,不含前缀
    protected $name = 'user_gangwei';


    protected static function init()
    {
        self::afterInsert(function ($row) {
            $row->save(['weigh' => $row['id']]);
        });
    }

    /**
     * 读取分类列表
     * @return array
     */
    public static function getCategoryArray()
    {
        $list = collection(self::order('weigh', 'desc')->select())->toArray();
        return $list;
    }
}
