@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | try { |
143 | 143 | return serialize($this->getCriteria()); |
144 | 144 | } catch (Exception $e) { |
145 | - return serialize($this->getCriteria()->map(function ($criterion) { |
|
145 | + return serialize($this->getCriteria()->map(function($criterion) { |
|
146 | 146 | return $this->serializeCriterion($criterion); |
147 | 147 | })); |
148 | 148 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | $key = $this->getCacheKey('all', func_get_args()); |
216 | 216 | $time = $this->getCacheTime(); |
217 | - $value = $this->getCacheRepository()->remember($key, $time, function () use ($columns) { |
|
217 | + $value = $this->getCacheRepository()->remember($key, $time, function() use ($columns) { |
|
218 | 218 | return parent::all($columns); |
219 | 219 | }); |
220 | 220 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $key = $this->getCacheKey('paginate', func_get_args()); |
242 | 242 | |
243 | 243 | $time = $this->getCacheTime(); |
244 | - $value = $this->getCacheRepository()->remember($key, $time, function () use ($limit, $columns, $method) { |
|
244 | + $value = $this->getCacheRepository()->remember($key, $time, function() use ($limit, $columns, $method) { |
|
245 | 245 | return parent::paginate($limit, $columns, $method); |
246 | 246 | }); |
247 | 247 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | $key = $this->getCacheKey('find', func_get_args()); |
268 | 268 | $time = $this->getCacheTime(); |
269 | - $value = $this->getCacheRepository()->remember($key, $time, function () use ($id, $columns) { |
|
269 | + $value = $this->getCacheRepository()->remember($key, $time, function() use ($id, $columns) { |
|
270 | 270 | return parent::find($id, $columns); |
271 | 271 | }); |
272 | 272 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | $key = $this->getCacheKey('findByField', func_get_args()); |
294 | 294 | $time = $this->getCacheTime(); |
295 | - $value = $this->getCacheRepository()->remember($key, $time, function () use ($field, $value, $columns) { |
|
295 | + $value = $this->getCacheRepository()->remember($key, $time, function() use ($field, $value, $columns) { |
|
296 | 296 | return parent::findByField($field, $value, $columns); |
297 | 297 | }); |
298 | 298 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | $key = $this->getCacheKey('findWhere', func_get_args()); |
319 | 319 | $time = $this->getCacheTime(); |
320 | - $value = $this->getCacheRepository()->remember($key, $time, function () use ($where, $columns) { |
|
320 | + $value = $this->getCacheRepository()->remember($key, $time, function() use ($where, $columns) { |
|
321 | 321 | return parent::findWhere($where, $columns); |
322 | 322 | }); |
323 | 323 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | |
342 | 342 | $key = $this->getCacheKey('getByCriteria', func_get_args()); |
343 | 343 | $time = $this->getCacheTime(); |
344 | - $value = $this->getCacheRepository()->remember($key, $time, function () use ($criteria) { |
|
344 | + $value = $this->getCacheRepository()->remember($key, $time, function() use ($criteria) { |
|
345 | 345 | return parent::getByCriteria($criteria); |
346 | 346 | }); |
347 | 347 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $search = $this->parserSearchValue($search); |
58 | 58 | $modelForceAndWhere = strtolower($searchJoin) === 'and'; |
59 | 59 | |
60 | - $model = $model->where(function ($query) use ($fields, $search, $searchData, $isFirstField, $modelForceAndWhere) { |
|
60 | + $model = $model->where(function($query) use ($fields, $search, $searchData, $isFirstField, $modelForceAndWhere) { |
|
61 | 61 | /** @var Builder $query */ |
62 | 62 | |
63 | 63 | foreach ($fields as $field => $condition) { |
@@ -74,72 +74,72 @@ discard block |
||
74 | 74 | if (isset($searchData[$field])) { |
75 | 75 | $value = ($condition == "like" || $condition == "ilike") ? "%{$searchData[$field]}%" : $searchData[$field]; |
76 | 76 | } else { |
77 | - if (!is_null($search) && !in_array($condition,['in','between'])) { |
|
77 | + if (!is_null($search) && !in_array($condition, ['in', 'between'])) { |
|
78 | 78 | $value = ($condition == "like" || $condition == "ilike") ? "%{$search}%" : $search; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | 82 | $relation = null; |
83 | - if(stripos($field, '.')) { |
|
83 | + if (stripos($field, '.')) { |
|
84 | 84 | $explode = explode('.', $field); |
85 | 85 | $field = array_pop($explode); |
86 | 86 | $relation = implode('.', $explode); |
87 | 87 | } |
88 | - if($condition === 'in'){ |
|
89 | - $value = explode(',',$value); |
|
90 | - if( trim($value[0]) === "" || $field == $value[0]){ |
|
88 | + if ($condition === 'in') { |
|
89 | + $value = explode(',', $value); |
|
90 | + if (trim($value[0]) === "" || $field == $value[0]) { |
|
91 | 91 | $value = null; |
92 | 92 | } |
93 | 93 | } |
94 | - if($condition === 'between'){ |
|
95 | - $value = explode(',',$value); |
|
96 | - if(count($value) < 2){ |
|
94 | + if ($condition === 'between') { |
|
95 | + $value = explode(',', $value); |
|
96 | + if (count($value) < 2) { |
|
97 | 97 | $value = null; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | $modelTableName = $query->getModel()->getTable(); |
101 | - if ( $isFirstField || $modelForceAndWhere ) { |
|
101 | + if ($isFirstField || $modelForceAndWhere) { |
|
102 | 102 | if (!is_null($value)) { |
103 | - if(!is_null($relation)) { |
|
104 | - $query->whereHas($relation, function($query) use($field,$condition,$value) { |
|
105 | - if($condition === 'in'){ |
|
106 | - $query->whereIn($field,$value); |
|
107 | - }elseif($condition === 'between'){ |
|
108 | - $query->whereBetween($field,$value); |
|
109 | - }else{ |
|
110 | - $query->where($field,$condition,$value); |
|
103 | + if (!is_null($relation)) { |
|
104 | + $query->whereHas($relation, function($query) use($field, $condition, $value) { |
|
105 | + if ($condition === 'in') { |
|
106 | + $query->whereIn($field, $value); |
|
107 | + }elseif ($condition === 'between') { |
|
108 | + $query->whereBetween($field, $value); |
|
109 | + } else { |
|
110 | + $query->where($field, $condition, $value); |
|
111 | 111 | } |
112 | 112 | }); |
113 | 113 | } else { |
114 | - if($condition === 'in'){ |
|
115 | - $query->whereIn($modelTableName.'.'.$field,$value); |
|
116 | - }elseif($condition === 'between'){ |
|
117 | - $query->whereBetween($modelTableName.'.'.$field,$value); |
|
118 | - }else{ |
|
119 | - $query->where($modelTableName.'.'.$field,$condition,$value); |
|
114 | + if ($condition === 'in') { |
|
115 | + $query->whereIn($modelTableName . '.' . $field, $value); |
|
116 | + }elseif ($condition === 'between') { |
|
117 | + $query->whereBetween($modelTableName . '.' . $field, $value); |
|
118 | + } else { |
|
119 | + $query->where($modelTableName . '.' . $field, $condition, $value); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | $isFirstField = false; |
123 | 123 | } |
124 | 124 | } else { |
125 | 125 | if (!is_null($value)) { |
126 | - if(!is_null($relation)) { |
|
127 | - $query->orWhereHas($relation, function($query) use($field,$condition,$value) { |
|
128 | - if($condition === 'in'){ |
|
129 | - $query->whereIn($field,$value); |
|
130 | - }elseif($condition === 'between'){ |
|
126 | + if (!is_null($relation)) { |
|
127 | + $query->orWhereHas($relation, function($query) use($field, $condition, $value) { |
|
128 | + if ($condition === 'in') { |
|
129 | + $query->whereIn($field, $value); |
|
130 | + }elseif ($condition === 'between') { |
|
131 | 131 | $query->whereBetween($field, $value); |
132 | - }else{ |
|
133 | - $query->where($field,$condition,$value); |
|
132 | + } else { |
|
133 | + $query->where($field, $condition, $value); |
|
134 | 134 | } |
135 | 135 | }); |
136 | 136 | } else { |
137 | - if($condition === 'in'){ |
|
138 | - $query->orWhereIn($modelTableName.'.'.$field, $value); |
|
139 | - }elseif($condition === 'between'){ |
|
140 | - $query->whereBetween($modelTableName.'.'.$field,$value); |
|
141 | - }else{ |
|
142 | - $query->orWhere($modelTableName.'.'.$field, $condition, $value); |
|
137 | + if ($condition === 'in') { |
|
138 | + $query->orWhereIn($modelTableName . '.' . $field, $value); |
|
139 | + }elseif ($condition === 'between') { |
|
140 | + $query->whereBetween($modelTableName . '.' . $field, $value); |
|
141 | + } else { |
|
142 | + $query->orWhere($modelTableName . '.' . $field, $condition, $value); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | if (isset($orderBy) && !empty($orderBy)) { |
152 | 152 | $orderBySplit = explode(';', $orderBy); |
153 | - if(count($orderBySplit) > 1) { |
|
153 | + if (count($orderBySplit) > 1) { |
|
154 | 154 | $sortedBySplit = explode(';', $sortedBy); |
155 | 155 | foreach ($orderBySplit as $orderBySplitItemKey => $orderBySplitItem) { |
156 | 156 | $sortedBy = isset($sortedBySplit[$orderBySplitItemKey]) ? $sortedBySplit[$orderBySplitItemKey] : $sortedBySplit[0]; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | protected function parserFieldsOrderBy($model, $orderBy, $sortedBy) |
192 | 192 | { |
193 | 193 | $split = explode('|', $orderBy); |
194 | - if(count($split) > 1) { |
|
194 | + if (count($split) > 1) { |
|
195 | 195 | /* |
196 | 196 | * ex. |
197 | 197 | * products|description -> join products on current_table.product_id = products.id order by description |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | $sortTable = $split[0]; |
210 | 210 | |
211 | 211 | $commaExp = explode(',', $split[1]); |
212 | - $keyName = $table.'.'.$split[1]; |
|
212 | + $keyName = $table . '.' . $split[1]; |
|
213 | 213 | if (count($commaExp) > 1) { |
214 | - $keyName = $table.'.'.$commaExp[0]; |
|
215 | - $localKey = '.'.$commaExp[1]; |
|
214 | + $keyName = $table . '.' . $commaExp[0]; |
|
215 | + $localKey = '.' . $commaExp[1]; |
|
216 | 216 | } |
217 | 217 | } else { |
218 | 218 | /* |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | * products -> product_id |
224 | 224 | */ |
225 | 225 | $prefix = Str::singular($sortTable); |
226 | - $keyName = $table.'.'.$prefix.'_id'; |
|
226 | + $keyName = $table . '.' . $prefix . '_id'; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | $model = $model |
230 | - ->leftJoin($sortTable, $keyName, '=', $sortTable.$localKey) |
|
230 | + ->leftJoin($sortTable, $keyName, '=', $sortTable . $localKey) |
|
231 | 231 | ->orderBy($sortColumn, $sortedBy) |
232 | - ->addSelect($table.'.*'); |
|
232 | + ->addSelect($table . '.*'); |
|
233 | 233 | } else { |
234 | 234 | $model = $model->orderBy($orderBy, $sortedBy); |
235 | 235 | } |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | $query->whereHas($relation, function($query) use($field,$condition,$value) { |
105 | 105 | if($condition === 'in'){ |
106 | 106 | $query->whereIn($field,$value); |
107 | - }elseif($condition === 'between'){ |
|
107 | + } elseif($condition === 'between'){ |
|
108 | 108 | $query->whereBetween($field,$value); |
109 | - }else{ |
|
109 | + } else{ |
|
110 | 110 | $query->where($field,$condition,$value); |
111 | 111 | } |
112 | 112 | }); |
113 | 113 | } else { |
114 | 114 | if($condition === 'in'){ |
115 | 115 | $query->whereIn($modelTableName.'.'.$field,$value); |
116 | - }elseif($condition === 'between'){ |
|
116 | + } elseif($condition === 'between'){ |
|
117 | 117 | $query->whereBetween($modelTableName.'.'.$field,$value); |
118 | - }else{ |
|
118 | + } else{ |
|
119 | 119 | $query->where($modelTableName.'.'.$field,$condition,$value); |
120 | 120 | } |
121 | 121 | } |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | $query->orWhereHas($relation, function($query) use($field,$condition,$value) { |
128 | 128 | if($condition === 'in'){ |
129 | 129 | $query->whereIn($field,$value); |
130 | - }elseif($condition === 'between'){ |
|
130 | + } elseif($condition === 'between'){ |
|
131 | 131 | $query->whereBetween($field, $value); |
132 | - }else{ |
|
132 | + } else{ |
|
133 | 133 | $query->where($field,$condition,$value); |
134 | 134 | } |
135 | 135 | }); |
136 | 136 | } else { |
137 | 137 | if($condition === 'in'){ |
138 | 138 | $query->orWhereIn($modelTableName.'.'.$field, $value); |
139 | - }elseif($condition === 'between'){ |
|
139 | + } elseif($condition === 'between'){ |
|
140 | 140 | $query->whereBetween($modelTableName.'.'.$field,$value); |
141 | - }else{ |
|
141 | + } else{ |
|
142 | 142 | $query->orWhere($modelTableName.'.'.$field, $condition, $value); |
143 | 143 | } |
144 | 144 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | foreach ($this->getFiles() as $stub => $file) { |
387 | 387 | $path = $this->domain->getDomainPath($this->getName()) . $file; |
388 | 388 | |
389 | - $this->component->task("Generating file {$path}",function () use ($stub, $path) { |
|
389 | + $this->component->task("Generating file {$path}", function() use ($stub, $path) { |
|
390 | 390 | if (!$this->filesystem->isDirectory($dir = dirname($path))) { |
391 | 391 | $this->filesystem->makeDirectory($dir, 0775, true); |
392 | 392 | } |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | { |
493 | 493 | $path = $this->domain->getDomainPath($this->getName()) . 'domain.json'; |
494 | 494 | |
495 | - $this->component->task("Generating file $path",function () use ($path) { |
|
495 | + $this->component->task("Generating file $path", function() use ($path) { |
|
496 | 496 | if (!$this->filesystem->isDirectory($dir = dirname($path))) { |
497 | 497 | $this->filesystem->makeDirectory($dir, 0775, true); |
498 | 498 | } |
@@ -140,7 +140,7 @@ |
||
140 | 140 | $process->setTimeout($this->timeout); |
141 | 141 | |
142 | 142 | if ($this->console instanceof Command) { |
143 | - $process->run(function ($type, $line) { |
|
143 | + $process->run(function($type, $line) { |
|
144 | 144 | $this->console->line($line); |
145 | 145 | }); |
146 | 146 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $paths = array_merge($paths, $this->config('scan.paths')); |
117 | 117 | } |
118 | 118 | |
119 | - $paths = array_map(function ($path) { |
|
119 | + $paths = array_map(function($path) { |
|
120 | 120 | return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*'); |
121 | 121 | }, $paths); |
122 | 122 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function getCached() |
202 | 202 | { |
203 | - return $this->cache->store($this->config->get('domains.cache.driver'))->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () { |
|
203 | + return $this->cache->store($this->config->get('domains.cache.driver'))->remember($this->config('cache.key'), $this->config('cache.lifetime'), function() { |
|
204 | 204 | return $this->toCollection()->toArray(); |
205 | 205 | }); |
206 | 206 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | { |
290 | 290 | $domains = $this->allEnabled(); |
291 | 291 | |
292 | - uasort($domains, function (Domain $a, Domain $b) use ($direction) { |
|
292 | + uasort($domains, function(Domain $a, Domain $b) use ($direction) { |
|
293 | 293 | if ($a->get('priority') === $b->get('priority')) { |
294 | 294 | return 0; |
295 | 295 | } |
@@ -42,12 +42,12 @@ |
||
42 | 42 | */ |
43 | 43 | protected function registerServices() |
44 | 44 | { |
45 | - $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) { |
|
45 | + $this->app->singleton(Contracts\RepositoryInterface::class, function($app) { |
|
46 | 46 | $path = $app['config']->get('domains.paths.domains'); |
47 | 47 | |
48 | 48 | return new Lumen\LumenFileRepository($app, $path); |
49 | 49 | }); |
50 | - $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { |
|
50 | + $this->app->singleton(Contracts\ActivatorInterface::class, function($app) { |
|
51 | 51 | $activator = $app['config']->get('domains.activator'); |
52 | 52 | $class = $app['config']->get('domains.activators.' . $activator)['class']; |
53 | 53 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $path = $this->app['config']->get('domains.stubs.path') ?? __DIR__ . '/Commands/stubs'; |
38 | 38 | Stub::setBasePath($path); |
39 | 39 | |
40 | - $this->app->booted(function ($app) { |
|
40 | + $this->app->booted(function($app) { |
|
41 | 41 | /** @var RepositoryInterface $domainRepository */ |
42 | 42 | $domainRepository = $app[RepositoryInterface::class]; |
43 | 43 | if ($domainRepository->config('stubs.enabled') === true) { |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | */ |
52 | 52 | protected function registerServices() |
53 | 53 | { |
54 | - $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) { |
|
54 | + $this->app->singleton(Contracts\RepositoryInterface::class, function($app) { |
|
55 | 55 | $path = $app['config']->get('domains.paths.domains'); |
56 | 56 | |
57 | 57 | return new Laravel\LaravelFileRepository($app, $path); |
58 | 58 | }); |
59 | - $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) { |
|
59 | + $this->app->singleton(Contracts\ActivatorInterface::class, function($app) { |
|
60 | 60 | $activator = $app['config']->get('domains.activator'); |
61 | 61 | $class = $app['config']->get('domains.activators.' . $activator)['class']; |
62 | 62 |
@@ -203,7 +203,7 @@ |
||
203 | 203 | $file = 'domain.json'; |
204 | 204 | } |
205 | 205 | |
206 | - return Arr::get($this->domainJson, $file, function () use ($file) { |
|
206 | + return Arr::get($this->domainJson, $file, function() use ($file) { |
|
207 | 207 | return $this->domainJson[$file] = new Json($this->getPath() . '/' . $file, $this->files); |
208 | 208 | }); |
209 | 209 | } |
@@ -183,7 +183,7 @@ |
||
183 | 183 | return $this->readJson(); |
184 | 184 | } |
185 | 185 | |
186 | - return $this->cache->store($this->config->get('domains.cache.driver'))->remember($this->cacheKey, $this->cacheLifetime, function () { |
|
186 | + return $this->cache->store($this->config->get('domains.cache.driver'))->remember($this->cacheKey, $this->cacheLifetime, function() { |
|
187 | 187 | return $this->readJson(); |
188 | 188 | }); |
189 | 189 | } |