Article.php 881 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. namespace fecshop\models\mysqldb\cms;
  10. use yii\db\ActiveRecord;
  11. use yii\base\InvalidValueException;
  12. /**
  13. * @author Terry Zhao <2358269014@qq.com>
  14. * @since 1.0
  15. */
  16. class Article extends ActiveRecord
  17. {
  18. const STATUS_DELETED = 10;
  19. const STATUS_ACTIVE = 1;
  20. public static function tableName()
  21. {
  22. return '{{%article}}';
  23. }
  24. public function beforeSave($insert)
  25. {
  26. foreach ($this->attributes() as $attr) {
  27. if (is_array($this->{$attr})) {
  28. throw new InvalidValueException('article model save fail, attribute ['.$attr. '] is array, you must serialize it before save ');
  29. }
  30. }
  31. return parent::beforeSave($insert);
  32. }
  33. }