Completed
Pull Request — ft/added-admin-pagination (#291)
by Philippe
39:17 queued 32:21
created
src/Relations/Relation.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@
 block discarded – undo
103 103
     {
104 104
         $relations = static::where(function ($query) use ($type, $id) {
105 105
             return $query->where('parent_type', $type)
106
-                         ->where('parent_id', $id);
106
+                            ->where('parent_id', $id);
107 107
         })->orWhere(function ($query) use ($type, $id) {
108 108
             return $query->where('child_type', $type)
109 109
                 ->where('child_id', $id);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             ->orderBy('sort', 'ASC')
52 52
             ->get();
53 53
 
54
-        return $relations->map(function (Relation $relation) {
54
+        return $relations->map(function(Relation $relation) {
55 55
             $parent = $relation->parent;
56 56
             $parent->relation = $relation;
57 57
             return $parent;
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
                             ->orderBy('sort', 'ASC')
66 66
                             ->get();
67 67
 
68
-        return $relations->map(function (Relation $relation) use ($parent_type, $parent_id) {
68
+        return $relations->map(function(Relation $relation) use ($parent_type, $parent_id) {
69 69
 
70 70
             // It could be that the child itself is soft-deleted, if this is the case, we will ignore it and move on.
71 71
             if (!$child = $relation->child) {
72 72
                 if (!$relation->child()->withTrashed()->first()) {
73 73
 //                if ((!method_exists($childInstance, 'trashed')) || ! $childInstance->onlyTrashed()->find($relation->child_id)) {
74 74
                     // If we cannot retrieve it then he collection type is possibly off, this is a database inconsistency and should be addressed
75
-                    throw new \DomainException('Corrupt relation reference. Related child ['.$relation->child_type.'@'.$relation->child_id.'] could not be retrieved for parent [' . $parent_type.'@'.$parent_id.']. Make sure the morph key can resolve to a valid class.');
75
+                    throw new \DomainException('Corrupt relation reference. Related child ['.$relation->child_type.'@'.$relation->child_id.'] could not be retrieved for parent ['.$parent_type.'@'.$parent_id.']. Make sure the morph key can resolve to a valid class.');
76 76
                 }
77 77
 
78 78
                 return null;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         })
85 85
 
86 86
         // In case of soft-deleted entries, this will be null and should be ignored. We make sure that keys are reset in case of removed child
87
-        ->reject(function ($child) {
87
+        ->reject(function($child) {
88 88
             return is_null($child);
89 89
         })
90 90
         ->values();
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 
102 102
     public static function deleteRelationsOf($type, $id)
103 103
     {
104
-        $relations = static::where(function ($query) use ($type, $id) {
104
+        $relations = static::where(function($query) use ($type, $id) {
105 105
             return $query->where('parent_type', $type)
106 106
                          ->where('parent_id', $id);
107
-        })->orWhere(function ($query) use ($type, $id) {
107
+        })->orWhere(function($query) use ($type, $id) {
108 108
             return $query->where('child_type', $type)
109 109
                 ->where('child_id', $id);
110 110
         })->get();
Please login to merge, or discard this patch.
src/Media/MediaType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Thinktomorrow\Chief\Media;
6 6
 
Please login to merge, or discard this patch.
src/Settings/Setting.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
     private function defaultField()
46 46
     {
47 47
         return InputField::make($this->key)
48
-                    ->label(ucfirst(str_replace(['-','_','.'], ' ', $this->key)));
48
+                    ->label(ucfirst(str_replace(['-', '_', '.'], ' ', $this->key)));
49 49
     }
50 50
 
51 51
     public static function refreshFieldsFromConfig()
Please login to merge, or discard this patch.
src/FlatReferences/FlatReferencePresenter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 {
9 9
     public static function toSelectValues(Collection $collection): Collection
10 10
     {
11
-        return $collection->map(function (ProvidesFlatReference $item) {
11
+        return $collection->map(function(ProvidesFlatReference $item) {
12 12
             return [
13 13
                 'id'    => $item->flatReference()->get(),
14 14
                 'label' => $item->flatReferenceLabel(),
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
     {
22 22
         $grouped = [];
23 23
 
24
-        static::toSelectValues($collection)->each(function ($item) use (&$grouped) {
24
+        static::toSelectValues($collection)->each(function($item) use (&$grouped) {
25 25
             if (isset($grouped[$item['group']])) {
26 26
                 $grouped[$item['group']]['values'][] = $item;
27
-            } else {
27
+            }else {
28 28
                 $grouped[$item['group']] = ['group' => $item['group'], 'values' => [$item]];
29 29
             }
30 30
         });
Please login to merge, or discard this patch.
src/FlatReferences/FlatReferenceCollection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@
 block discarded – undo
21 21
             $referenceStrings = [];
22 22
         }
23 23
 
24
-        return (new Collection($referenceStrings))->reject(function ($referenceString) {
24
+        return (new Collection($referenceStrings))->reject(function($referenceString) {
25 25
             return is_null($referenceString);
26
-        })->map(function ($referenceString) {
26
+        })->map(function($referenceString) {
27 27
             return FlatReferenceFactory::fromString($referenceString)->instance();
28 28
         });
29 29
     }
30 30
 
31 31
     public function toFlatReferences(): Collection
32 32
     {
33
-        return (new Collection($this->all()))->map(function (ProvidesFlatReference $item) {
33
+        return (new Collection($this->all()))->map(function(ProvidesFlatReference $item) {
34 34
             return $item->flatReference()->get();
35 35
         });
36 36
     }
Please login to merge, or discard this patch.
src/FlatReferences/FlatReferenceFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
     public static function fromString(string $reference): FlatReference
8 8
     {
9 9
         if (false == strpos($reference, '@')) {
10
-            throw new \InvalidArgumentException('Invalid reference composition. A flat reference should honour schema <class>@<id>. [' . $reference . '] was passed instead.');
10
+            throw new \InvalidArgumentException('Invalid reference composition. A flat reference should honour schema <class>@<id>. ['.$reference.'] was passed instead.');
11 11
         }
12 12
 
13 13
         list($className, $id) = explode('@', $reference);
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
         $instance = app($className);
16 16
         $instance->{$instance->getKeyName()} = $id;
17 17
 
18
-        if (! method_exists($instance, 'flatReference')) {
19
-            throw new \InvalidArgumentException('Instance created from model reference [' . $reference . '] was expected to have a method of flatReference() but is has not.');
18
+        if (!method_exists($instance, 'flatReference')) {
19
+            throw new \InvalidArgumentException('Instance created from model reference ['.$reference.'] was expected to have a method of flatReference() but is has not.');
20 20
         }
21 21
 
22 22
         return $instance->flatReference();
Please login to merge, or discard this patch.
src/Pages/PublishedFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
     public function apply($value = null): Closure
21 21
     {
22
-        return function ($query) use ($value) {
22
+        return function($query) use ($value) {
23 23
             if ($value == 'all') {
24 24
                 return $query;
25 25
             }
Please login to merge, or discard this patch.
src/Pages/Console/GeneratePage.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 
38 38
         // Set required paths
39 39
         $this->dirs = ['base' => $this->settings['base_path'] ?? base_path()];
40
-        $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'] .'/'. config('thinktomorrow.chief.domain.path', 'src');
41
-        $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'] . '/resources/views';
42
-        $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'] . '/app/Http/Controllers';
43
-        $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'] . '/routes/web.php';
40
+        $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'].'/'.config('thinktomorrow.chief.domain.path', 'src');
41
+        $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'].'/resources/views';
42
+        $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'].'/app/Http/Controllers';
43
+        $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'].'/routes/web.php';
44 44
     }
45 45
 
46 46
     public function handle()
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
     private function publishModel()
63 63
     {
64 64
         $this->publishFile(
65
-            __DIR__ . '/stubs/model.php.stub',
66
-            $to = $this->dirs['model'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php',
65
+            __DIR__.'/stubs/model.php.stub',
66
+            $to = $this->dirs['model'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php',
67 67
             'model'
68 68
         );
69 69
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
     private function publishController()
74 74
     {
75 75
         $this->publishFile(
76
-            __DIR__ . '/stubs/controller.php.stub',
77
-            $to = $this->dirs['controller'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php',
76
+            __DIR__.'/stubs/controller.php.stub',
77
+            $to = $this->dirs['controller'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php',
78 78
             'controller'
79 79
         );
80 80
     }
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
     private function modelTraits()
114 114
     {
115 115
         return [
116
-            '\\' . Publishable::class,
117
-            '\\' . Sortable::class,
116
+            '\\'.Publishable::class,
117
+            '\\'.Sortable::class,
118 118
             'q' => 'Proceed.',
119 119
         ];
120 120
     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     protected function publishFile($from, $to, $type)
130 130
     {
131 131
         if ($this->filesystem->exists($to) && !$this->option('force')) {
132
-            if (!$this->confirm('File [' . $to . '] already exists? Overwrite this file?')) {
132
+            if (!$this->confirm('File ['.$to.'] already exists? Overwrite this file?')) {
133 133
                 return;
134 134
             }
135 135
         }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
         $to = str_replace($this->dirs['base'], '', realpath($to));
170 170
 
171
-        $this->line('<info>Copied ' . $type . '</info> <comment>[' . $from . ']</comment> <info>To</info> <comment>[' . $to . ']</comment>');
171
+        $this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>');
172 172
     }
173 173
 
174 174
     protected function replacePlaceholders($content)
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
     private function generateImportStatements(): string
188 188
     {
189 189
         return collect(['\\'.Page::class])
190
-            ->map(function ($statement) {
191
-                return 'use ' . $statement . ";\n    ";
190
+            ->map(function($statement) {
191
+                return 'use '.$statement.";\n    ";
192 192
             })->implode('');
193 193
     }
194 194
 
195 195
     private function generateTraitStatements(): string
196 196
     {
197 197
         return collect($this->chosenTraits)
198
-            ->map(function ($statement) {
199
-                return 'use ' . $statement . ";\n    ";
198
+            ->map(function($statement) {
199
+                return 'use '.$statement.";\n    ";
200 200
             })->implode('');
201 201
     }
202 202
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
         // We make an estimated guess based on the project name. At Think Tomorrow, we
217 217
         // have a src folder which is PSR-4 namespaced by the project name itself.
218
-        return str_replace('\\\\', '\\', ucfirst(config('thinktomorrow.chief.domain.namespace', 'App')).'\\'. ucfirst($this->plural));
218
+        return str_replace('\\\\', '\\', ucfirst(config('thinktomorrow.chief.domain.namespace', 'App')).'\\'.ucfirst($this->plural));
219 219
     }
220 220
 
221 221
     private function addToConfig($configKey, $value)
Please login to merge, or discard this patch.
src/Sets/SetReference.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         // Constraints
36 36
         if (!isset($values['action'])) {
37
-            throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: ' . print_r($values, true));
37
+            throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: '.print_r($values, true));
38 38
         }
39 39
 
40 40
         return new static(
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $sets = config('thinktomorrow.chief.sets', []);
51 51
 
52
-        return collect($sets)->map(function ($set, $key) {
52
+        return collect($sets)->map(function($set, $key) {
53 53
             return SetReference::fromArray($key, $set);
54 54
         });
55 55
     }
56 56
 
57 57
     public static function find($key): ?SetReference
58 58
     {
59
-        return static::all()->filter(function ($ref) use ($key) {
59
+        return static::all()->filter(function($ref) use ($key) {
60 60
             return $ref->key() == $key;
61 61
         })->first();
62 62
     }
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 
74 74
         $this->validateAction($class, $method);
75 75
 
76
-        $result = call_user_func_array([app($class),$method], $this->parameters);
76
+        $result = call_user_func_array([app($class), $method], $this->parameters);
77 77
 
78
-        if (! $result instanceof Set && $result instanceof Collection) {
78
+        if (!$result instanceof Set && $result instanceof Collection) {
79 79
             return new Set($result->all(), $this->key);
80 80
         }
81 81
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
     private static function validateAction($class, $method)
109 109
     {
110
-        if (! class_exists($class)) {
110
+        if (!class_exists($class)) {
111 111
             throw new \InvalidArgumentException('The class ['.$class.'] isn\'t a valid class reference or does not exist in the chief-settings.sets config entry.');
112 112
         }
113 113
 
Please login to merge, or discard this patch.