123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace app\admin\model;
- use support\Model;
- /**
- * 系统配置分类表模型
- * Class SystemConfigClassify
- * @package app\api\model
- */
- class SystemConfigClassify extends Model
- {
- const WAIT = '0';
- const DONE = '1';
- const MEMBER_AUTH_STATUS = [
- self::WAIT => '停用',
- self::DONE => '启用',
- ];
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'system_config_classify';
- public $timestamps = false;
- /**
- * Notes:子集模型关联
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- * User: yym
- * Date: 2022/10/10
- */
- public function children()
- {
- return $this->hasMany(SystemConfigClassify::class, 'classify_pid', 'classify_id');
- }
- /**
- * Notes:设置分类列表
- * @return array
- * User: yym
- * Date: 2022/10/10
- */
- public static function getClassifyList()
- {
- return static::where(['classify_pid' => 0])
- ->with(['children'])
- ->orderBy('classify_sort', 'desc')
- ->get()
- ->toArray();
- }
- /**
- * Notes:插入数据
- * @param array $data
- * @return false|int
- * User: yym
- * Date: 2022/10/10
- */
- public static function insertData(array $data)
- {
- if(empty($data))
- {
- return false;
- }
- return static::insertGetId($data);
- }
- /**
- * Notes:根据主键获取单个信息
- * @param int $classify_id
- * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
- * User: yym
- * Date: 2022/10/10
- */
- public static function getInfo(int $classify_id)
- {
- return static::where(['classify_id' => $classify_id])->first();
- }
- /**
- * Notes:根据主键更新信息
- * @param int $classify_id
- * @param array $data
- * @return false|int
- * User: yym
- * Date: 2022/10/10
- */
- public static function updateData(int $classify_id, array $data)
- {
- if(empty($classify_id) || empty($data))
- {
- return false;
- }
- return static::where(['classify_id' => $classify_id])->update($data);
- }
- }
|