@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // If no view has been created for this page collection, we try once again to fetch the content value if any. This will silently fail |
| 53 | 53 | // if no content value is present. We don't consider the 'content' attribute to be a default as we do for module. |
| 54 | - return $this->map(function ($item) { |
|
| 54 | + return $this->map(function($item) { |
|
| 55 | 55 | return ($this->viewParent && $item instanceof ViewableContract) |
| 56 | 56 | ? $item->setViewParent($this->viewParent)->renderView() |
| 57 | 57 | : ($item->content ?? ''); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $currentPage = $currentPage ?? request()->get('page', 1); |
| 86 | 86 | $path = request()->path(); |
| 87 | - $items = array_slice($this->all(), ($currentPage - 1) * $perPage); |
|
| 87 | + $items = array_slice($this->all(), ($currentPage-1) * $perPage); |
|
| 88 | 88 | |
| 89 | 89 | return (new \Illuminate\Pagination\Paginator($items, $perPage ?? $this->paginateSetting('perPage', '12'), $currentPage))->setPath($path); |
| 90 | 90 | } |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $currentPage = $currentPage ?? request()->get('page', 1); |
| 103 | 103 | $path = '/'.request()->path(); |
| 104 | - $items = array_slice($this->all(), ($currentPage - 1) * $perPage, $perPage); |
|
| 104 | + $items = array_slice($this->all(), ($currentPage-1) * $perPage, $perPage); |
|
| 105 | 105 | |
| 106 | 106 | return (new \Illuminate\Pagination\LengthAwarePaginator($items, $this->paginateSetting('total', $this->count()), $perPage ?? $this->paginateSetting('perPage', '12'), $currentPage))->setPath($path); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | private function paginateSetting($key, $default = null) |
| 110 | 110 | { |
| 111 | - if(!isset($this->settings['paginate']) || !isset($this->settings['paginate'][$key])) return $default; |
|
| 111 | + if (!isset($this->settings['paginate']) || !isset($this->settings['paginate'][$key])) return $default; |
|
| 112 | 112 | |
| 113 | 113 | return $this->settings['paginate'][$key]; |
| 114 | 114 | } |
@@ -108,7 +108,9 @@ |
||
| 108 | 108 | |
| 109 | 109 | private function paginateSetting($key, $default = null) |
| 110 | 110 | { |
| 111 | - if(!isset($this->settings['paginate']) || !isset($this->settings['paginate'][$key])) return $default; |
|
| 111 | + if(!isset($this->settings['paginate']) || !isset($this->settings['paginate'][$key])) { |
|
| 112 | + return $default; |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | 115 | return $this->settings['paginate'][$key]; |
| 114 | 116 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | // Constraints |
| 41 | 41 | if (!isset($values['action'])) { |
| 42 | - throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: ' . print_r($values, true)); |
|
| 42 | + throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: '.print_r($values, true)); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | return new static( |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $sets = config('thinktomorrow.chief.sets', []); |
| 56 | 56 | |
| 57 | - return collect($sets)->map(function ($set, $key) { |
|
| 57 | + return collect($sets)->map(function($set, $key) { |
|
| 58 | 58 | return SetReference::fromArray($key, $set); |
| 59 | 59 | }); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public static function find($key): ?SetReference |
| 63 | 63 | { |
| 64 | - return static::all()->filter(function ($ref) use ($key) { |
|
| 64 | + return static::all()->filter(function($ref) use ($key) { |
|
| 65 | 65 | return $ref->key() == $key; |
| 66 | 66 | })->first(); |
| 67 | 67 | } |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $this->validateAction($class, $method); |
| 80 | 80 | |
| 81 | - $result = call_user_func_array([app($class),$method], $this->parameters($class, $method, $parent)); |
|
| 81 | + $result = call_user_func_array([app($class), $method], $this->parameters($class, $method, $parent)); |
|
| 82 | 82 | |
| 83 | - if (! $result instanceof Set && $result instanceof Collection) { |
|
| 83 | + if (!$result instanceof Set && $result instanceof Collection) { |
|
| 84 | 84 | return new Set($result->all(), $this->key); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if (! $result instanceof Set && $result instanceof Paginator) { |
|
| 87 | + if (!$result instanceof Set && $result instanceof Paginator) { |
|
| 88 | 88 | return new Set($result->all(), $this->key, [ |
| 89 | 89 | 'paginate' => [ |
| 90 | 90 | 'total' => $result->total(), |
@@ -104,22 +104,22 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function parameters(string $class, string $method, ActsAsParent $parent): array |
| 106 | 106 | { |
| 107 | - try{ |
|
| 107 | + try { |
|
| 108 | 108 | $parameters = $this->parameters; |
| 109 | 109 | |
| 110 | 110 | $reflection = new \ReflectionClass($class); |
| 111 | - foreach($reflection->getMethod($method)->getParameters() as $parameter){ |
|
| 112 | - if($parameter->getType() && $parameter->getType()->getName() == ActsAsParent::class){ |
|
| 111 | + foreach ($reflection->getMethod($method)->getParameters() as $parameter) { |
|
| 112 | + if ($parameter->getType() && $parameter->getType()->getName() == ActsAsParent::class) { |
|
| 113 | 113 | $parameters[] = $parent; |
| 114 | 114 | } |
| 115 | - if($parameter->getType() && $parameter->getType()->getName() == Request::class){ |
|
| 115 | + if ($parameter->getType() && $parameter->getType()->getName() == Request::class) { |
|
| 116 | 116 | $parameters[] = request(); |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $parameters; |
| 121 | 121 | } |
| 122 | - catch(\Exception $e) { |
|
| 122 | + catch (\Exception $e) { |
|
| 123 | 123 | if (config('thinktomorrow.chief.strict')) { |
| 124 | 124 | throw $e; |
| 125 | 125 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | private static function validateAction($class, $method) |
| 155 | 155 | { |
| 156 | - if (! class_exists($class)) { |
|
| 156 | + if (!class_exists($class)) { |
|
| 157 | 157 | throw new \InvalidArgumentException('The class ['.$class.'] isn\'t a valid class reference or does not exist in the chief-settings.sets config entry.'); |
| 158 | 158 | } |
| 159 | 159 | |