VideoCat.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. use yii\db\ActiveRecord;
  6. class VideoCat extends ActiveRecord
  7. {
  8. const STATUS_ON = 1;
  9. const STATUS_OFF = 0;
  10. const IS_DELETE = 1;
  11. const IS_NOT_DELETE = 0;
  12. public function behaviors()
  13. {
  14. return [
  15. [
  16. 'class' => TimestampBehavior::className(),
  17. 'attributes' => [
  18. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
  19. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
  20. ],
  21. ],
  22. ];
  23. }
  24. /**
  25. * @inheritdoc
  26. */
  27. public static function tableName()
  28. {
  29. return '{{%video_cat}}'; // 数据库表名
  30. }
  31. /**
  32. * @inheritdoc
  33. */
  34. public function rules()
  35. {
  36. return [
  37. [['store_id', 'name',], 'required'],
  38. [['store_id', 'status', 'is_delete'], 'integer'],
  39. [['created_at', 'updated_at'], 'safe'],
  40. [['name'], 'string', 'max' => 255],
  41. [['status', 'is_delete'], 'default', 'value' => 0]
  42. ];
  43. }
  44. /**
  45. * @inheritdoc
  46. */
  47. public function attributeLabels()
  48. {
  49. return [
  50. 'id' => 'ID',
  51. 'store_id' => 'Store ID',
  52. 'name' => 'Name',
  53. 'status' => 'Status',
  54. 'created_at' => 'Created At',
  55. 'updated_at' => 'Updated At',
  56. 'is_delete' => 'Is Delete',
  57. ];
  58. }
  59. }