Tag.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace common\models\member;
  3. use common\behaviors\MerchantBehavior;
  4. /**
  5. * This is the model class for table "{{%member_tag}}".
  6. *
  7. * @property int $id 主键
  8. * @property int|null $merchant_id 商户id
  9. * @property string $title 标题
  10. * @property int|null $sort 排序
  11. * @property int|null $status 状态
  12. * @property int $created_at 创建时间
  13. * @property int $updated_at 更新时间
  14. */
  15. class Tag extends \common\models\base\BaseModel
  16. {
  17. use MerchantBehavior;
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return '{{%member_tag}}';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['merchant_id', 'sort', 'status', 'created_at', 'updated_at'], 'integer'],
  32. [['title'], 'string', 'max' => 50],
  33. [['title'], 'required'],
  34. ];
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'id' => '主键',
  43. 'merchant_id' => '商户id',
  44. 'title' => '标题',
  45. 'sort' => '排序',
  46. 'status' => '状态',
  47. 'created_at' => '创建时间',
  48. 'updated_at' => '更新时间',
  49. ];
  50. }
  51. /**
  52. * 关联中间表
  53. *
  54. * @return \yii\db\ActiveQuery
  55. */
  56. public function getTagMap()
  57. {
  58. return $this->hasOne(TagMap::class, ['tag_id' => 'id']);
  59. }
  60. public function afterDelete()
  61. {
  62. TagMap::deleteAll(['tag_id' => $this->id]);
  63. parent::afterDelete();
  64. }
  65. }
粤ICP备19079148号