GoodsBrand.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\models\common\admin\log\CommonActionLog;
  9. use Yii;
  10. use yii\behaviors\TimestampBehavior;
  11. /**
  12. * This is the model class for table "{{%goods_cat}}".
  13. *
  14. * @property integer $id
  15. * @property integer $store_id
  16. * @property string $brand_name
  17. * @property string $brand_logo
  18. * @property integer $is_delete
  19. * @property integer $sort
  20. * @property integer $is_show
  21. * @property string $created_at
  22. * @property string $updated_at
  23. */
  24. class GoodsBrand extends \yii\db\ActiveRecord
  25. {
  26. /**
  27. * @inheritdoc
  28. */
  29. public static function tableName()
  30. {
  31. return '{{%goods_brand}}';
  32. }
  33. /**
  34. * @inheritdoc
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['store_id', 'is_delete', 'sort', 'is_show'], 'integer'],
  40. [['brand_name', 'brand_logo', 'created_at', 'updated_at'], 'string'],
  41. ];
  42. }
  43. public function behaviors()
  44. {
  45. return [
  46. [
  47. 'class' => TimestampBehavior::class,
  48. ]
  49. ];
  50. }
  51. /**
  52. * @inheritdoc
  53. */
  54. public function attributeLabels()
  55. {
  56. return [
  57. 'id' => 'ID',
  58. 'store_id' => 'Store ID',
  59. 'brand_name' => '品牌名称',
  60. 'brand_logo' => '品牌logo',
  61. 'is_delete' => '是否删除',
  62. 'sort' => '排序(越大越靠前)',
  63. 'created_at' => '添加时间',
  64. 'updated_at' => '修改时间',
  65. 'is_show' => '是否显示',
  66. ];
  67. }
  68. // public function afterSave($insert, $changedAttributes)
  69. // {
  70. /*$data = $insert ? json_encode($this->attributes) : json_encode($changedAttributes);
  71. CommonActionLog::storeActionLog('', $insert, $this->is_delete, $data, $this->id);*/
  72. // }
  73. public static function getList($store_id) {
  74. return self::find()->where(['store_id' => $store_id, 'is_delete' => 0, 'is_show' => 1])
  75. ->select('id, brand_name, brand_logo')->orderBy('id DESC')->asArray()->all();
  76. }
  77. }