MchBrands.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * MchBrands.php
  4. * todo 文件描述
  5. * Created on 2025/5/13 08:49
  6. * @author: hankaige
  7. */
  8. namespace app\models;
  9. use yii\behaviors\TimestampBehavior;
  10. class MchBrands extends \yii\db\ActiveRecord
  11. {
  12. CONST NOT_DELETE = 0;
  13. CONST IS_DELETE = 1;
  14. CONST STATUS_ON = 1;
  15. CONST STATUS_OFF = 0;
  16. /**
  17. * @inheritdoc
  18. */
  19. public static function tableName()
  20. {
  21. return '{{%mch_brands}}';
  22. }
  23. public function rules()
  24. {
  25. return [
  26. [['store_id', 'sort', 'is_delete', 'status', 'created_at', 'updated_at'],'integer'],
  27. [['name'], 'string'],
  28. [['store_id', 'user_id', 'name'], 'required'],
  29. ];
  30. }
  31. public function behaviors()
  32. {
  33. return [
  34. [
  35. 'class' => TimestampBehavior::class,
  36. ]
  37. ];
  38. }
  39. public function getUser(){
  40. return $this->hasOne(User::class, ['id' => 'user_id'])->select(['id', 'username', 'nickname', 'avatar_url']);
  41. }
  42. }