| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use Yii;
- /**
- * This is the model class for table "{{%banner}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property string $pic_url
- * @property string $title
- * @property string $page_url
- * @property integer $sort
- * @property integer $created_at
- * @property integer $is_delete
- * @property integer $type
- * @property string $open_type
- * @property integer $md_id
- */
- class Banner extends \yii\db\ActiveRecord
- {
- /**
- * 商城
- */
- const TYPE_STORE = 1;
- /**
- * 点餐
- */
- const TYPE_FOOD = 2;
- /**
- * SAAS
- */
- const TYPE_SAAS = 3;
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%banner}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['store_id', 'pic_url', 'title'], 'required'],
- [['store_id', 'sort', 'created_at', 'is_delete', 'type', 'md_id'], 'integer'],
- [['pic_url', 'page_url'], 'string'],
- [['title', 'open_type'], 'string', 'max' => 255],
- ['type', 'default', 'value' => 1,],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => '商城id',
- 'pic_url' => '图片url',
- 'title' => '标题',
- 'page_url' => '页面路径',
- 'sort' => '排序,升序',
- 'created_at' => '添加时间',
- 'is_delete' => '是否删除:0=未删除,1=已删除',
- 'type' => '类型1 => 商城,2 => 点餐',
- 'open_type' => 'Open Type',
- ];
- }
- /**
- * @return array
- */
- public function saveBanner()
- {
- if ($this->validate()) {
- if ($this->save()) {
- return [
- 'code' => 0,
- 'msg' => '成功'
- ];
- } else {
- return [
- 'code' => 1,
- 'msg' => '失败'
- ];
- }
- } else {
- return $this->errors[0];
- }
- }
- }
|