| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace addons\Album\common\models;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "qimall_addons_album_page_share".
- *
- * @property int $id
- * @property int $album_id 画册ID
- * @property int $album_page_id 画册页ID
- * @property int $mall_id
- * @property int $user_id
- * @property int $created_at 分享时间
- * @property int $updated_at 更新时间
- * @property string $date 日期
- */
- class AddonsAlbumPageShare extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_album_page_share}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['album_id', 'album_page_id', 'mall_id', 'user_id', 'created_at','updated_at'], 'integer'],
- [['date'], 'required'],
- [['date'], 'safe'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'album_id' => '画册ID',
- 'album_page_id' => '画册页ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'created_at' => '分享时间',
- 'date' => '日期',
- 'updated_at' => '更新时间',
- ];
- }
- /**
- * @Author: ltm
- * @DateTime: 2022/2/15 0015 11:43
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return string
- */
- public static function setData(array $params){
- try{
- $params['created_at'] = time();
- $params['updated_at'] = time();
- $params['date'] = date("Y-m-d");
- if (!empty($params['id'])) {
- $model = self::findOne(['id'=>$params['id'],'mall_id'=>$params['mall_id']]);
- if (empty($model)) throw new Exception('记录不存在或已删除');
- }else{
- $model = new self();
- $model->loadDefaultValues();
- }
- $model->mall_id = $params['mall_id'];
- if(!$model->load($params,'') || !$model->save()){
- throw new Exception($model->getErrorMessage());
- }
- return $model;
- }catch(\Exception $e){
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- public function getAlbum()
- {
- return $this->hasOne(AddonsAlbum::class, ['id' => 'album_id'])->select('id,title,goods_count');
- }
- }
|