Completed
Push — master ( ce0ce3...9e2c54 )
by Vladimir
01:37
created
src/data/SearchResult.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
     public static function sortByModel(array $searchResults)
85 85
     {
86 86
         $sorted = [];
87
-        foreach($searchResults as $obj) {
87
+        foreach ($searchResults as $obj) {
88 88
             $sorted[$obj->modelName][] = $obj;
89 89
         }
90 90
         return $sorted;
Please login to merge, or discard this patch.
src/SearchComponent.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 use Yii;
11 11
 use yii\base\Component;
12 12
 use yii\base\InvalidConfigException;
13
-use yii\base\Model;;
13
+use yii\base\Model; ;
14 14
 use yii\db\ActiveRecordInterface;
15 15
 use yii\helpers\ArrayHelper;
16 16
 use vintage\search\data\SearchResult;
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
      * @throws InvalidConfigException
68 68
      */
69 69
     public function search($query) {
70
-        foreach($this->models as $model) {
70
+        foreach ($this->models as $model) {
71 71
             /* @var ActiveRecordInterface|SearchInterface|Model $searchModel */
72 72
             $searchModel = Yii::createObject($model['class']);
73 73
 
74
-            if($this->isSearchModel($searchModel)) {
74
+            if ($this->isSearchModel($searchModel)) {
75 75
                 $activeQuery = $searchModel::find();
76 76
 
77
-                foreach($searchModel->getSearchFields() as $field) {
78
-                    if($searchModel->hasAttribute($field)) {
77
+                foreach ($searchModel->getSearchFields() as $field) {
78
+                    if ($searchModel->hasAttribute($field)) {
79 79
                         $activeQuery->orWhere(['like', $field, $query]);
80 80
                     } else {
81 81
                         throw new \Exception(sprintf("Field `%s` not found in `%s` model", $field, $model['class']));
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                 }
84 84
 
85 85
                 $foundModels = $activeQuery->all();
86
-                if($foundModels !== null) {
86
+                if ($foundModels !== null) {
87 87
                     $this->_currentModel = $searchModel;
88 88
                     $this->addToResult($foundModels);
89 89
                 }
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function getModelLabel($modelName)
107 107
     {
108
-        foreach($this->models as $model) {
109
-            if($model['class'] == $modelName) {
108
+        foreach ($this->models as $model) {
109
+            if ($model['class'] == $modelName) {
110 110
                 return $model['label'];
111 111
             }
112 112
         }
Please login to merge, or discard this patch.