GoodsBrandCat.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.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_brand_cat}}".
  13. *
  14. * @property integer $id
  15. * @property integer $store_id
  16. * @property string $brand_cat_name
  17. * @property integer $is_delete
  18. * @property integer $sort
  19. * @property integer $status
  20. * @property string $created_at
  21. * @property string $updated_at
  22. */
  23. class GoodsBrandCat extends \yii\db\ActiveRecord
  24. {
  25. const STATUS_OPEN = 1;
  26. const STATUS_CLOSE = 0;
  27. /**
  28. * @inheritdoc
  29. */
  30. public static function tableName()
  31. {
  32. return '{{%goods_brand_cat}}';
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function rules()
  38. {
  39. return [
  40. [['store_id', 'is_delete', 'sort', 'status'], 'integer'],
  41. [['brand_cat_name', 'created_at', 'updated_at'], 'string'],
  42. ];
  43. }
  44. public function behaviors()
  45. {
  46. return [
  47. [
  48. 'class' => TimestampBehavior::class,
  49. ]
  50. ];
  51. }
  52. /**
  53. * @inheritdoc
  54. */
  55. public function attributeLabels()
  56. {
  57. return [
  58. 'id' => 'ID',
  59. 'store_id' => 'Store ID',
  60. 'brand_cat_name' => '品牌分类名称',
  61. 'is_delete' => '是否删除',
  62. 'sort' => '排序(越大越靠前)',
  63. 'created_at' => '添加时间',
  64. 'updated_at' => '修改时间',
  65. 'status' => '是否显示',
  66. ];
  67. }
  68. public static function getList($store_id) {
  69. return self::find()->where(['store_id' => $store_id, 'is_delete' => 0, 'status' => 1])
  70. ->select('id, brand_cat_name')->orderBy('id DESC')->asArray()->all();
  71. }
  72. //获取指定的商品品牌分类
  73. public static function getBrandCat($id) {
  74. return self::findOne(['id' => $id, 'is_delete' => 0, 'status' => 1]);
  75. }
  76. }