You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.8 KiB

  1. <?php
  2. namespace goods\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "atg_brand".
  7. *
  8. * @property int $id
  9. * @property string $name 品牌名
  10. * @property int $is_delete 是否删除,1为已删除
  11. * @property int $created_at 创建时间
  12. * @property int $updated_at 更新时间
  13. */
  14. class Brand extends \yii\db\ActiveRecord
  15. {
  16. //是否删除is_delete
  17. const IS_DELETE_NO = 0;//未删除
  18. const IS_DELETE_YES = 1;//已删除
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return 'atg_brand';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['name'], 'required'],
  33. [['is_delete'], 'integer'],
  34. [['name'], 'string', 'max' => 50],
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'id',
  44. 'name' => '品牌名',
  45. 'is_delete' => '是否删除,1为已删除',
  46. 'created_at' => '创建时间',
  47. 'updated_at' => '更新时间',
  48. ];
  49. }
  50. /**
  51. * @author linyao
  52. * @email 602604991@qq.com
  53. * @created Nov 8, 2019
  54. *
  55. * 行为存储创建时间和更新时间
  56. */
  57. public function behaviors()
  58. {
  59. return [
  60. [
  61. 'class' => TimestampBehavior::className(),
  62. 'createdAtAttribute' => 'created_at',
  63. 'updatedAtAttribute' => 'updated_at',
  64. 'value' => function() {
  65. return time();
  66. },
  67. ],
  68. ];
  69. }
  70. public static function modelColumn()
  71. {
  72. return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
  73. }
  74. }