BusinessRightInfo.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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\Upload;
  9. use Yii;
  10. /**
  11. * This is the model class for table "{{%banner}}".
  12. *
  13. * @property integer $id
  14. * @property integer $store_id
  15. * @property string $pic_url
  16. * @property string $title
  17. * @property string $page_url
  18. * @property integer $sort
  19. * @property integer $created_at
  20. * @property integer $is_delete
  21. * @property integer $type
  22. * @property string $open_type
  23. * @property integer $md_id
  24. */
  25. class BusinessRightInfo extends \yii\db\ActiveRecord
  26. {
  27. /**
  28. * @inheritdoc
  29. */
  30. public static function tableName()
  31. {
  32. return '{{%business_right_info}}';
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'id' => 'ID',
  41. 'name' => '权限名称',
  42. 'explanation' => '权限说明',
  43. ];
  44. }
  45. public static function resetRightInfo($rightIds = [], $field = '') {
  46. $query = self::find()->where(['is_delete' => 0])->orderBy('id ASC');
  47. if (!empty($rightIds)) {
  48. $query->andWhere(['id' => $rightIds]);
  49. }
  50. if (trim($field)) {
  51. $query->select($field);
  52. }
  53. $rightInfo = $query->asArray()->all();
  54. $resetData = [];
  55. foreach ($rightInfo as $index => &$item) {
  56. if (intval($item['id']) === 3) {
  57. $resetData = $item;
  58. unset($rightInfo[$index]);
  59. }
  60. if (intval($item['id']) === 4) {
  61. $item['name'] = $resetData['name'];
  62. $item['explanation'] = $resetData['explanation'];
  63. }
  64. }
  65. return array_values($rightInfo);
  66. }
  67. }