@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | { |
28 | 28 | $types = config('thinktomorrow.chief.menus', []); |
29 | 29 | |
30 | - return collect($types)->map(function ($menu, $key) { |
|
30 | + return collect($types)->map(function($menu, $key) { |
|
31 | 31 | return new static($key, $menu['label'], $menu['view']); |
32 | 32 | }); |
33 | 33 | } |
34 | 34 | |
35 | 35 | public static function find($key): ?self |
36 | 36 | { |
37 | - return static::all()->filter(function ($menu) use ($key) { |
|
37 | + return static::all()->filter(function($menu) use ($key) { |
|
38 | 38 | return $menu->key() == $key; |
39 | 39 | })->first(); |
40 | 40 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | $menu = []; |
85 | 85 | |
86 | - $this->items()->each(function ($item) use (&$menu) { |
|
86 | + $this->items()->each(function($item) use (&$menu) { |
|
87 | 87 | $menu[] = sprintf('<li><a href="%s">%s</a></li>', $item->url, $item->label); |
88 | 88 | }); |
89 | 89 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $files = collect(); |
26 | 26 | |
27 | 27 | foreach ($paths as $path) { |
28 | - if (! $fullpath = self::constructFullPath($path)) { |
|
28 | + if (!$fullpath = self::constructFullPath($path)) { |
|
29 | 29 | continue; |
30 | 30 | } |
31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - return static::$loadedSnippets = new static($files->map(function (SplFileInfo $file) { |
|
40 | + return static::$loadedSnippets = new static($files->map(function(SplFileInfo $file) { |
|
41 | 41 | $path = $file->getRealPath(); |
42 | 42 | |
43 | 43 | if (0 === strpos($path, resource_path('views')) && false !== strpos($file->getBasename(), '.blade.php')) { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | $key = substr($file->getBasename(), 0, strpos($file->getBasename(), '.')); |
48 | - $label = ucfirst(str_replace(['-','_'], ' ', $key)); |
|
48 | + $label = ucfirst(str_replace(['-', '_'], ' ', $key)); |
|
49 | 49 | |
50 | 50 | return new Snippet($key, $label, $path); |
51 | 51 | })->all()); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $loadedSnippets = static::load(); |
57 | 57 | |
58 | - return $loadedSnippets->first(function (Snippet $snippet) use ($key) { |
|
58 | + return $loadedSnippets->first(function(Snippet $snippet) use ($key) { |
|
59 | 59 | return $snippet->key() == $key; |
60 | 60 | }); |
61 | 61 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | public function toClips(): array |
88 | 88 | { |
89 | - return $this->map(function ($snippet) { |
|
89 | + return $this->map(function($snippet) { |
|
90 | 90 | return [$snippet->label(), $snippet->placeholder()]; |
91 | 91 | })->toArray(); |
92 | 92 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\Snippets; |
6 | 6 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | return $value; |
13 | 13 | } |
14 | 14 | |
15 | - $value = preg_replace_callback(static::$pattern, function ($matches) { |
|
15 | + $value = preg_replace_callback(static::$pattern, function($matches) { |
|
16 | 16 | |
17 | 17 | // First entry of matches contains our full captured group, which we want to replace. |
18 | 18 | // Second entry is the text itself, without the brackets |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\Filters; |
6 | 6 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | public function render(array $requestInput = []): string |
52 | 52 | { |
53 | - $path = $this->viewpath ?? 'chief::back._filters.' . $this->type; |
|
53 | + $path = $this->viewpath ?? 'chief::back._filters.'.$this->type; |
|
54 | 54 | $this->default($requestInput[$this->name] ?? null); |
55 | 55 | |
56 | 56 | return view($path, ['filter' => $this])->render(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | if (!in_array($name, ['name', 'label', 'description', 'query', 'viewpath', 'default'])) { |
67 | - throw new \InvalidArgumentException('Cannot set value by ['. $name .'].'); |
|
67 | + throw new \InvalidArgumentException('Cannot set value by ['.$name.'].'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->values[$name] = $arguments[0]; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | { |
38 | 38 | $requestInput = request()->all(); |
39 | 39 | |
40 | - return array_reduce($this->all(), function ($carry, Filter $filter) use ($requestInput) { |
|
41 | - return $carry . $filter->render($requestInput); |
|
40 | + return array_reduce($this->all(), function($carry, Filter $filter) use ($requestInput) { |
|
41 | + return $carry.$filter->render($requestInput); |
|
42 | 42 | }, ''); |
43 | 43 | } |
44 | 44 | |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | |
55 | 55 | public function keys(): array |
56 | 56 | { |
57 | - return array_map(function (Filter $filter) { |
|
57 | + return array_map(function(Filter $filter) { |
|
58 | 58 | return $filter->key(); |
59 | 59 | }, $this->filters); |
60 | 60 | } |
61 | 61 | |
62 | 62 | private function validateFilters(array $filters) |
63 | 63 | { |
64 | - array_map(function (Filter $filter) { |
|
64 | + array_map(function(Filter $filter) { |
|
65 | 65 | }, $filters); |
66 | 66 | } |
67 | 67 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | public function offsetSet($offset, $value) |
88 | 88 | { |
89 | - if (! $value instanceof Filter) { |
|
90 | - throw new \InvalidArgumentException('Passed value must be of type ' . Filter::class); |
|
89 | + if (!$value instanceof Filter) { |
|
90 | + throw new \InvalidArgumentException('Passed value must be of type '.Filter::class); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $this->filters[$offset] = $value; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | private function sanitizeFilters(array $filters) |
107 | 107 | { |
108 | - return array_map(function ($filter) { |
|
108 | + return array_map(function($filter) { |
|
109 | 109 | if (is_string($filter) && class_exists($filter)) { |
110 | 110 | return $filter::init(); |
111 | 111 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | public function apply($value = null): Closure |
17 | 17 | { |
18 | - return $this->query && $this->query instanceof Closure ? $this->query : function ($query) { |
|
18 | + return $this->query && $this->query instanceof Closure ? $this->query : function($query) { |
|
19 | 19 | return $query; |
20 | 20 | }; |
21 | 21 | } |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | |
7 | 7 | class FilterType |
8 | 8 | { |
9 | - const INPUT = 'input'; // oneliner text (input) |
|
10 | - const SELECT = 'select'; // Select options |
|
9 | + const INPUT = 'input'; // oneliner text (input) |
|
10 | + const SELECT = 'select'; // Select options |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @var string |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | static::INPUT, |
21 | 21 | static::SELECT, |
22 | 22 | ])) { |
23 | - throw new \Exception('Invalid type identifier given [' . $type . '].'); |
|
23 | + throw new \Exception('Invalid type identifier given ['.$type.'].'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $this->type = $type; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | public static function fromString(string $type) |
30 | 30 | { |
31 | - $class = 'Thinktomorrow\Chief\Filters\Types\\' . ucfirst($type . 'Filter'); |
|
31 | + $class = 'Thinktomorrow\Chief\Filters\Types\\'.ucfirst($type.'Filter'); |
|
32 | 32 | |
33 | 33 | return new $class(new static($type)); |
34 | 34 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | foreach ($manager->fields() as $field) { |
19 | 19 | |
20 | 20 | // Custom save methods |
21 | - $saveMethodName = 'save'. ucfirst(camel_case($field->key())) . 'Field'; |
|
21 | + $saveMethodName = 'save'.ucfirst(camel_case($field->key())).'Field'; |
|
22 | 22 | if (method_exists($manager, $saveMethodName)) { |
23 | 23 | $this->saveMethods[$field->key] = ['field' => $field, 'method' => $saveMethodName]; |
24 | 24 | continue; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | // Media fields are treated separately |
28 | 28 | if ($field->ofType(FieldType::MEDIA, FieldType::DOCUMENT)) { |
29 | - if (! isset($this->saveMethods['_files'])) { |
|
29 | + if (!isset($this->saveMethods['_files'])) { |
|
30 | 30 | $this->saveMethods['_files'] = ['field' => new Fields([$field]), 'method' => 'uploadMedia']; |
31 | 31 | continue; |
32 | 32 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | // Custom set methods - default is the generic setField() method. |
39 | - $methodName = 'set'. ucfirst(camel_case($field->key())) . 'Field'; |
|
39 | + $methodName = 'set'.ucfirst(camel_case($field->key())).'Field'; |
|
40 | 40 | (method_exists($manager, $methodName)) |
41 | 41 | ? $manager->$methodName($field, $request) |
42 | 42 | : $manager->setField($field, $request); |