| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * @Author: your name
- * @Date: 2021-05-08 17:28:23
- * @LastEditTime: 2021-05-12 16:35:15
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\modules\client\models\v1\admin\CatForm.php
- */
- namespace app\modules\client\models\v1\admin;
- use app\models\Cat;
- use yii\base\Model;
- class CatForm extends Model
- {
- public $store_id = 1;
- public $parent_id;
- public $sort;
- public $name;
- public $pic_url;
- public $is_show;
- public $model;
- public $is_delete;
- /**
- * @return array
- */
- public function rules()
- {
- return [
- [['parent_id', 'store_id', 'sort'], 'integer'],
- [['name'], 'string', 'max' => 60],
- [['pic_url'], 'string'],
- [['is_show'], 'default', 'value' => 1],
- [['is_delete'], 'default', 'value' => 0]
- ];
- }
- /**
- * 保存分类
- * @return array
- */
- public function save()
- {
- $this->model->parent_id = $this->parent_id;
- $this->model->is_show = $this->is_show;
- $this->model->name = $this->name;
- $this->model->pic_url = $this->pic_url;
- $this->model->sort = $this->sort;
- $this->model->store_id = $this->store_id;
- if ($this->model->save()) {
- return [
- 'code' => 0,
- 'msg' => '提交成功'
- ];
- } else {
- return [
- 'code' => 0,
- 'msg' => '保存失败'
- ];
- }
- }
- /**
- * Undocumented function
- *
- * @Author LGL 24963@qq.com
- * @DateTime 2021-01-18
- * @desc: 根据id获取分类列表
- * @param array $id
- * @return void
- */
- public static function getCatListById ($id = [])
- {
- if (empty($id) && !is_array($id)) {
- return [];
- }
- return Cat::find()->where(['in', 'id', $id])->select('id, name, pic_url')->asArray()->all();
- }
- }
|