Test Setup Failed
Push — a-simpler-manager ( b87bbb...ca6085 )
by Ben
06:19 queued 13s
created
src/Shared/Concerns/Viewable/Viewable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
         }
68 68
 
69 69
         if (config('chief.strict')) {
70
-            throw new NotFoundViewKey('Missing view key. Please add a [viewKey] property to ' . get_class($this));
70
+            throw new NotFoundViewKey('Missing view key. Please add a [viewKey] property to '.get_class($this));
71 71
         }
72 72
 
73 73
         return '';
Please login to merge, or discard this patch.
src/Setup/Console/GeneratePage.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 
40 40
         // Set required paths
41 41
         $this->dirs = ['base' => $this->settings['base_path'] ?? base_path()];
42
-        $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'] . '/' . config('chief.domain.path', 'src');
43
-        $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'] . '/resources/views';
44
-        $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'] . '/app/Http/Controllers';
45
-        $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'] . '/routes/web.php';
42
+        $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'].'/'.config('chief.domain.path', 'src');
43
+        $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'].'/resources/views';
44
+        $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'].'/app/Http/Controllers';
45
+        $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'].'/routes/web.php';
46 46
     }
47 47
 
48 48
     public function handle()
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
     private function publishModel()
65 65
     {
66 66
         $this->publishFile(
67
-            __DIR__ . '/stubs/model.php.stub',
68
-            $to = $this->dirs['model'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php',
67
+            __DIR__.'/stubs/model.php.stub',
68
+            $to = $this->dirs['model'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php',
69 69
             'model'
70 70
         );
71 71
 
72
-        $this->addToConfig('collections', [$this->plural => $this->guessNamespace() . '\\' . ucfirst($this->singular)]);
72
+        $this->addToConfig('collections', [$this->plural => $this->guessNamespace().'\\'.ucfirst($this->singular)]);
73 73
     }
74 74
 
75 75
     private function publishController()
76 76
     {
77 77
         $this->publishFile(
78
-            __DIR__ . '/stubs/controller.php.stub',
79
-            $to = $this->dirs['controller'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php',
78
+            __DIR__.'/stubs/controller.php.stub',
79
+            $to = $this->dirs['controller'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php',
80 80
             'controller'
81 81
         );
82 82
     }
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
     private function modelTraits()
116 116
     {
117 117
         return [
118
-            '\\' . Publishable::class,
119
-            '\\' . Sortable::class,
118
+            '\\'.Publishable::class,
119
+            '\\'.Sortable::class,
120 120
             'q' => 'Proceed.',
121 121
         ];
122 122
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     protected function publishFile($from, $to, $type)
132 132
     {
133 133
         if ($this->filesystem->exists($to) && !$this->option('force')) {
134
-            if (!$this->confirm('File [' . $to . '] already exists? Overwrite this file?')) {
134
+            if (!$this->confirm('File ['.$to.'] already exists? Overwrite this file?')) {
135 135
                 return;
136 136
             }
137 137
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
         $to = str_replace($this->dirs['base'], '', realpath($to));
172 172
 
173
-        $this->line('<info>Copied ' . $type . '</info> <comment>[' . $from . ']</comment> <info>To</info> <comment>[' . $to . ']</comment>');
173
+        $this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>');
174 174
     }
175 175
 
176 176
     protected function replacePlaceholders($content)
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 
189 189
     private function generateImportStatements(): string
190 190
     {
191
-        return collect(['\\' . Page::class])
192
-            ->map(function ($statement) {
193
-                return 'use ' . $statement . ";\n    ";
191
+        return collect(['\\'.Page::class])
192
+            ->map(function($statement) {
193
+                return 'use '.$statement.";\n    ";
194 194
             })->implode('');
195 195
     }
196 196
 
197 197
     private function generateTraitStatements(): string
198 198
     {
199 199
         return collect($this->chosenTraits)
200
-            ->map(function ($statement) {
201
-                return 'use ' . $statement . ";\n    ";
200
+            ->map(function($statement) {
201
+                return 'use '.$statement.";\n    ";
202 202
             })->implode('');
203 203
     }
204 204
 
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
 
218 218
         // We make an estimated guess based on the project name. At Think Tomorrow, we
219 219
         // have a src folder which is PSR-4 namespaced by the project name itself.
220
-        return str_replace('\\\\', '\\', ucfirst(config('chief.domain.namespace', 'App')) . '\\' . ucfirst($this->plural));
220
+        return str_replace('\\\\', '\\', ucfirst(config('chief.domain.namespace', 'App')).'\\'.ucfirst($this->plural));
221 221
     }
222 222
 
223 223
     private function addToConfig($configKey, $value)
224 224
     {
225
-        $current_values = config('chief.' . $configKey);
225
+        $current_values = config('chief.'.$configKey);
226 226
 
227 227
         if (is_array($current_values)) {
228 228
             $value = array_merge($current_values, $value);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
         // Find value - note: this regex does not work for nested arrays!
239 239
         // Also creates array with the non-short syntax.
240
-        $content = preg_replace('/[\'|"]' . $key . '[\'|"] ?=> ?(\[[^\]]*\]|[\'|"].*[\'|"])/', var_export($value, true), $content);
240
+        $content = preg_replace('/[\'|"]'.$key.'[\'|"] ?=> ?(\[[^\]]*\]|[\'|"].*[\'|"])/', var_export($value, true), $content);
241 241
 
242 242
         file_put_contents($file, $content);
243 243
     }
Please login to merge, or discard this patch.
src/Site/Urls/Application/SaveUrlSlugs.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     private function saveRecord(ProvidesUrl $model, string $locale, ?string $slug, Collection $existingRecords, bool $strict = true)
44 44
     {
45 45
         // Existing ones for this locale?
46
-        $nonRedirectsWithSameLocale = $existingRecords->filter(function ($record) use ($locale) {
46
+        $nonRedirectsWithSameLocale = $existingRecords->filter(function($record) use ($locale) {
47 47
             return (
48 48
                 $record->locale == $locale &&
49 49
                 !$record->isRedirect()
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         // If slug entry is left empty, all existing records will be deleted
54 54
         if (!$slug) {
55
-            $nonRedirectsWithSameLocale->each(function ($existingRecord) {
55
+            $nonRedirectsWithSameLocale->each(function($existingRecord) {
56 56
                 $existingRecord->delete();
57 57
             });
58 58
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         }
70 70
 
71 71
         // Only replace the existing records that differ from the current passed slugs
72
-        $nonRedirectsWithSameLocale->each(function ($existingRecord) use ($slug) {
72
+        $nonRedirectsWithSameLocale->each(function($existingRecord) use ($slug) {
73 73
             if ($existingRecord->slug != $slug) {
74 74
                 $existingRecord->replaceAndRedirect(['slug' => $slug]);
75 75
             }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $this->deleteIdenticalRedirects($sameExistingRecords, $locale, $slug);
99 99
 
100 100
         // Also delete any urls that match this locale and slug but are related to another model
101
-        if(!$this->strict) {
101
+        if (!$this->strict) {
102 102
             $this->deleteIdenticalRecords($model, $sameExistingRecords);
103 103
         }
104 104
     }
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function deleteIdenticalRedirects($existingRecords, $locale, $slug): void
114 114
     {
115
-        $existingRecords->filter(function ($record) use ($locale) {
115
+        $existingRecords->filter(function($record) use ($locale) {
116 116
             return (
117 117
                 $record->locale == $locale &&
118 118
                 $record->isRedirect()
119 119
             );
120
-        })->each(function ($existingRecord) use ($slug) {
120
+        })->each(function($existingRecord) use ($slug) {
121 121
             if ($existingRecord->slug == $slug) {
122 122
                 $existingRecord->delete();
123 123
             }
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
     {
129 129
         // The old homepage url should be removed since this is no longer in effect.
130 130
         // In case of any redirect to this old homepage, the last used redirect is now back in effect.
131
-        $existingRecords->reject(function ($existingRecord) use($model) {
131
+        $existingRecords->reject(function($existingRecord) use($model) {
132 132
             return (
133 133
                 $existingRecord->model_type == $model->getMorphClass() &&
134 134
                 $existingRecord->model_id == $model->id);
135
-        })->each(function ($existingRecord) {
135
+        })->each(function($existingRecord) {
136 136
 
137 137
             // TODO: if there is a redirect to this page, we'll take this one as the new url
138 138
             $existingRecord->delete();
Please login to merge, or discard this patch.
src/ManagedModels/Assistants/ManagedModelDefaults.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function adminLabel(string $key, $default = null, array $replace = [])
23 23
     {
24
-        if (! ($value = data_get($this->adminLabels(), $key)) ) {
24
+        if (!($value = data_get($this->adminLabels(), $key))) {
25 25
             return $default;
26 26
         }
27 27
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     private function adminLabels(): array
38 38
     {
39
-        $singular = Str::of(static::managedModelKey())->singular()->replace('_',' ')->__toString();
39
+        $singular = Str::of(static::managedModelKey())->singular()->replace('_', ' ')->__toString();
40 40
 
41 41
         return [
42 42
             /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
              */
47 47
             'label' => $singular, // Label used to refer to the generic model
48 48
             'nav_label' => $singular, // label used in the chief navigation
49
-            'page_title' => Str::of(static::managedModelKey())->plural()->replace('_',' ')->__toString(), // Generic collection title, for example used on index
49
+            'page_title' => Str::of(static::managedModelKey())->plural()->replace('_', ' ')->__toString(), // Generic collection title, for example used on index
50 50
 
51 51
             /**
52 52
              * Instance labels
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
 
64 64
     private function onlineStatusAsLabel(): string
65 65
     {
66
-        if(!$this instanceof StatefulContract) return '';
66
+        if (!$this instanceof StatefulContract) return '';
67 67
 
68 68
         if ($this->stateOf(PageState::KEY) === PageState::PUBLISHED) {
69 69
             return $this instanceof ProvidesUrl
70
-                ? '<a href="' . $this->url() . '" target="_blank"><em>online</em></a>'
70
+                ? '<a href="'.$this->url().'" target="_blank"><em>online</em></a>'
71 71
                 : '<span><em>online</em></span>';
72 72
         }
73 73
 
74 74
         if ($this->stateOf(PageState::KEY) === PageState::DRAFT) {
75 75
             return $this instanceof ProvidesUrl
76
-                ? '<a href="' . $this->url() . '" target="_blank" class="text-error"><em>offline</em></a>'
76
+                ? '<a href="'.$this->url().'" target="_blank" class="text-error"><em>offline</em></a>'
77 77
                 : '<span class="text-error"><em>offline</em></span>';
78 78
         }
79 79
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 
64 64
     private function onlineStatusAsLabel(): string
65 65
     {
66
-        if(!$this instanceof StatefulContract) return '';
66
+        if(!$this instanceof StatefulContract) {
67
+            return '';
68
+        }
67 69
 
68 70
         if ($this->stateOf(PageState::KEY) === PageState::PUBLISHED) {
69 71
             return $this instanceof ProvidesUrl
Please login to merge, or discard this patch.
src/Managers/Assistants/ArchiveAssistant.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
     public function routesArchiveAssistant(): array
21 21
     {
22 22
         return [
23
-            ManagedRoute::post('archive','archive/{id}'),
24
-            ManagedRoute::post('unarchive','unarchive/{id}'),
23
+            ManagedRoute::post('archive', 'archive/{id}'),
24
+            ManagedRoute::post('unarchive', 'unarchive/{id}'),
25 25
             ManagedRoute::get('archive_index'),
26 26
         ];
27 27
     }
28 28
 
29 29
     public function canArchiveAssistant(string $action, $model = null): bool
30 30
     {
31
-        if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false;
31
+        if (!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false;
32 32
 
33 33
         try {
34 34
             $this->authorize('update-page');
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
             return false;
37 37
         }
38 38
 
39
-        if($action === 'archive_index') {
39
+        if ($action === 'archive_index') {
40 40
             // Archive index is only visitable when there is at least one model archived.
41
-            if(public_method_exists($this->managedModelClass(), 'scopeArchived')) {
41
+            if (public_method_exists($this->managedModelClass(), 'scopeArchived')) {
42 42
                 return $this->managedModelClass()::archived()->count() > 0;
43 43
             }
44 44
             return false;
45 45
         }
46 46
 
47
-        if(!$model || !$model instanceof StatefulContract) return false;
47
+        if (!$model || !$model instanceof StatefulContract) return false;
48 48
 
49 49
         return PageState::make($model)->can($action);
50 50
     }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
             // Ok now get all urls from this model and point them to the new records
66 66
             foreach ($archivedUrlRecords as $urlRecord) {
67
-                if ($targetRecord = $targetRecords->first(function ($record) use ($urlRecord) {
67
+                if ($targetRecord = $targetRecords->first(function($record) use ($urlRecord) {
68 68
                     return ($record->locale == $urlRecord->locale && !$record->isRedirect());
69 69
                 })) {
70 70
                     $urlRecord->redirectTo($targetRecord);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
         Audit::activity()->performedOn($model)->log('archived');
86 86
 
87
-        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is gearchiveerd.');
87
+        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is gearchiveerd.');
88 88
     }
89 89
 
90 90
     public function unarchive(Request $request, $id)
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
         Audit::activity()->performedOn($model)->log('unarchived');
99 99
 
100
-        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is uit het archief gehaald.');
100
+        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is uit het archief gehaald.');
101 101
     }
102 102
 
103 103
     public function archiveIndex(Request $request)
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function canArchiveAssistant(string $action, $model = null): bool
30 30
     {
31
-        if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false;
31
+        if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) {
32
+            return false;
33
+        }
32 34
 
33 35
         try {
34 36
             $this->authorize('update-page');
@@ -44,7 +46,9 @@  discard block
 block discarded – undo
44 46
             return false;
45 47
         }
46 48
 
47
-        if(!$model || !$model instanceof StatefulContract) return false;
49
+        if(!$model || !$model instanceof StatefulContract) {
50
+            return false;
51
+        }
48 52
 
49 53
         return PageState::make($model)->can($action);
50 54
     }
Please login to merge, or discard this patch.
src/Managers/Assistants/ManagerDefaults.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function route(string $action, $model = null, ...$parameters): string
30 30
     {
31
-        foreach(DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) {
32
-            if(null !== ($route = $this->$method($action, $model, ...$parameters))){
31
+        foreach (DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) {
32
+            if (null !== ($route = $this->$method($action, $model, ...$parameters))) {
33 33
                 return $route;
34 34
             }
35 35
         }
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function can(string $action, $model = null): bool
41 41
     {
42
-        foreach(DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) {
43
-            if(true === $this->$method($action, $model)){
42
+        foreach (DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) {
43
+            if (true === $this->$method($action, $model)) {
44 44
                 return true;
45 45
             }
46 46
         }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             $parameters = array_merge((array)$modelId, $parameters);
57 57
         }
58 58
 
59
-        return route('chief.' . $this->managedModelClass()::managedModelKey() . '.' . $action, $parameters);
59
+        return route('chief.'.$this->managedModelClass()::managedModelKey().'.'.$action, $parameters);
60 60
     }
61 61
 
62 62
     private function guard(string $action, $model = null)
Please login to merge, or discard this patch.
src/Managers/Assistants/PublishAssistant.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,21 +18,21 @@  discard block
 block discarded – undo
18 18
     public function routesPublishAssistant(): array
19 19
     {
20 20
         return [
21
-            ManagedRoute::post('publish','publish/{id}'),
22
-            ManagedRoute::post('unpublish','unpublish/{id}'),
21
+            ManagedRoute::post('publish', 'publish/{id}'),
22
+            ManagedRoute::post('unpublish', 'unpublish/{id}'),
23 23
         ];
24 24
     }
25 25
 
26 26
     public function routePublishAssistant(string $action, $model = null, ...$parameters): ?string
27 27
     {
28
-        if(!$this->canPublishAssistant($action, $model)) return null;
28
+        if (!$this->canPublishAssistant($action, $model)) return null;
29 29
 
30 30
         return $this->generateRoute($action, $model, ...$parameters);
31 31
     }
32 32
 
33 33
     public function canPublishAssistant(string $action, $model = null): bool
34 34
     {
35
-        if(!in_array($action, ['publish', 'unpublish'])) return false;
35
+        if (!in_array($action, ['publish', 'unpublish'])) return false;
36 36
 
37 37
         try {
38 38
             $this->authorize('update-page');
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             return false;
41 41
         }
42 42
 
43
-        if(!$model || !$model instanceof StatefulContract) return false;
43
+        if (!$model || !$model instanceof StatefulContract) return false;
44 44
 
45 45
         return PageState::make($model)->can($action);
46 46
     }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
         Audit::activity()->performedOn($model)->log('published');
57 57
 
58
-        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is online geplaatst.');
58
+        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is online geplaatst.');
59 59
     }
60 60
 
61 61
     public function unpublish(Request $request, $id)
@@ -68,6 +68,6 @@  discard block
 block discarded – undo
68 68
 
69 69
         Audit::activity()->performedOn($model)->log('unpublished');
70 70
 
71
-        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is offline gehaald.');
71
+        return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is offline gehaald.');
72 72
     }
73 73
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,14 +25,18 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function routePublishAssistant(string $action, $model = null, ...$parameters): ?string
27 27
     {
28
-        if(!$this->canPublishAssistant($action, $model)) return null;
28
+        if(!$this->canPublishAssistant($action, $model)) {
29
+            return null;
30
+        }
29 31
 
30 32
         return $this->generateRoute($action, $model, ...$parameters);
31 33
     }
32 34
 
33 35
     public function canPublishAssistant(string $action, $model = null): bool
34 36
     {
35
-        if(!in_array($action, ['publish', 'unpublish'])) return false;
37
+        if(!in_array($action, ['publish', 'unpublish'])) {
38
+            return false;
39
+        }
36 40
 
37 41
         try {
38 42
             $this->authorize('update-page');
@@ -40,7 +44,9 @@  discard block
 block discarded – undo
40 44
             return false;
41 45
         }
42 46
 
43
-        if(!$model || !$model instanceof StatefulContract) return false;
47
+        if(!$model || !$model instanceof StatefulContract) {
48
+            return false;
49
+        }
44 50
 
45 51
         return PageState::make($model)->can($action);
46 52
     }
Please login to merge, or discard this patch.
src/Managers/Assistants/CrudAssistant.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function canCrudAssistant(string $action, $model = null): bool
41 41
     {
42
-        if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false;
42
+        if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) {
43
+            return false;
44
+        }
43 45
 
44 46
         try {
45 47
 
@@ -58,9 +60,13 @@  discard block
 block discarded – undo
58 60
             return false;
59 61
         }
60 62
 
61
-        if(in_array($action, ['index', 'create', 'store'])) return true;
63
+        if(in_array($action, ['index', 'create', 'store'])) {
64
+            return true;
65
+        }
62 66
 
63
-        if(!$model || !$model instanceof StatefulContract) return true;
67
+        if(!$model || !$model instanceof StatefulContract) {
68
+            return true;
69
+        }
64 70
 
65 71
         // Model cannot be in deleted state for editing purposes.
66 72
         if(in_array($action, ['edit', 'update'])) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function canCrudAssistant(string $action, $model = null): bool
39 39
     {
40
-        if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false;
40
+        if (!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false;
41 41
 
42 42
         try {
43 43
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
             return false;
57 57
         }
58 58
 
59
-        if(in_array($action, ['index', 'create', 'store'])) return true;
59
+        if (in_array($action, ['index', 'create', 'store'])) return true;
60 60
 
61
-        if(!$model || !$model instanceof StatefulContract) return true;
61
+        if (!$model || !$model instanceof StatefulContract) return true;
62 62
 
63 63
         // Model cannot be in deleted state for editing purposes.
64
-        if(in_array($action, ['edit', 'update'])) {
64
+        if (in_array($action, ['edit', 'update'])) {
65 65
             return !($model->stateOf(PageState::KEY) == PageState::DELETED);
66 66
         }
67 67
 
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
         // Default sorted by publish date
100 100
         $modelClass = $this->managedModelClass();
101 101
         if (Schema::hasColumn((new $modelClass)->getTable(), 'published_at')) {
102
-            $filters = $filters->add(HiddenFilter::make('publish', function ($query) {
102
+            $filters = $filters->add(HiddenFilter::make('publish', function($query) {
103 103
                 return $query->orderBy('published_at', 'DESC');
104 104
             }));
105 105
         }
106 106
 
107 107
         // if model has no timestamps, updated_at doesn't exist
108 108
         if ((new $modelClass)->timestamps) {
109
-            $filters = $filters->add(HiddenFilter::make('updated', function ($query) {
109
+            $filters = $filters->add(HiddenFilter::make('updated', function($query) {
110 110
                 return $query->orderBy('updated_at', 'DESC');
111 111
             }));
112 112
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         $model->saveFields($model->fields()->notTagged('edit'), $request->all(), $request->allFiles());
141 141
 
142 142
         return redirect()->to($this->route('edit', $model))
143
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is toegevoegd');
143
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is toegevoegd');
144 144
     }
145 145
 
146 146
     public function edit(Request $request, $id)
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $model->saveFields($model->fields()->notTagged('create'), $request->all(), $request->allFiles());
168 168
 
169 169
         return redirect()->to($this->route('index'))
170
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  <a href="' . $this->route('edit', $model) . '">' . $model->adminLabel('title') . '</a> is aangepast');
170
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  <a href="'.$this->route('edit', $model).'">'.$model->adminLabel('title').'</a> is aangepast');
171 171
     }
172 172
 
173 173
     public function delete(Request $request, $id)
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
         $this->guard('delete', $model);
178 178
 
179 179
         if ($request->get('deleteconfirmation') !== 'DELETE') {
180
-            return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.');
180
+            return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.');
181 181
         }
182 182
 
183 183
         app(DeleteModel::class)->handle($model);
184 184
 
185 185
         return redirect()->to($this->route('index'))
186
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is verwijderd.');
186
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is verwijderd.');
187 187
     }
188 188
 }
Please login to merge, or discard this patch.
src/ManagedModels/Fields/Fields.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function find(string $key): Field
42 42
     {
43
-        if(!isset($this->fields[$key])) {
44
-            throw new \InvalidArgumentException('No field found by key ' . $key);
43
+        if (!isset($this->fields[$key])) {
44
+            throw new \InvalidArgumentException('No field found by key '.$key);
45 45
         }
46 46
 
47 47
         return $this->fields[$key];
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 continue;
109 109
             }
110 110
 
111
-            $method = 'get' . ucfirst($key);
111
+            $method = 'get'.ucfirst($key);
112 112
 
113 113
             // Reject from list if value does not match expected one
114 114
             if ($value && $value == $field->$method()) {
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
 
125 125
     public function render(): string
126 126
     {
127
-        return array_reduce($this->fields, function (string $carry, Field $field) {
128
-            return $carry . $field->render();
127
+        return array_reduce($this->fields, function(string $carry, Field $field) {
128
+            return $carry.$field->render();
129 129
         }, '');
130 130
     }
131 131
 
132 132
     public function keyed($key): Fields
133 133
     {
134
-        $keys = (array) $key;
134
+        $keys = (array)$key;
135 135
 
136
-        return new static(array_filter($this->fields, function (Field $field) use ($keys) {
136
+        return new static(array_filter($this->fields, function(Field $field) use ($keys) {
137 137
             return in_array($field->getKey(), $keys);
138 138
         }));
139 139
     }
140 140
 
141 141
     public function tagged($tag): Fields
142 142
     {
143
-        return new static(array_filter($this->fields, function (Field $field) use ($tag) {
143
+        return new static(array_filter($this->fields, function(Field $field) use ($tag) {
144 144
             return $field->tagged($tag);
145 145
         }));
146 146
     }
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
     public function notTagged($tag): Fields
149 149
     {
150 150
         // TODO: to test this...
151
-        return new static(array_filter($this->fields, function (Field $field) use ($tag) {
151
+        return new static(array_filter($this->fields, function(Field $field) use ($tag) {
152 152
             return !$field->tagged($tag);
153 153
         }));
154 154
     }
155 155
 
156 156
     public function untagged(): Fields
157 157
     {
158
-        return new static(array_filter($this->fields, function (Field $field) {
158
+        return new static(array_filter($this->fields, function(Field $field) {
159 159
             return $field->untagged();
160 160
         }));
161 161
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     public function offsetGet($offset)
198 198
     {
199 199
         if (!isset($this->fields[$offset])) {
200
-            throw new \RuntimeException('No field found by key [' . $offset . ']');
200
+            throw new \RuntimeException('No field found by key ['.$offset.']');
201 201
         }
202 202
 
203 203
         return $this->fields[$offset];
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public function offsetSet($offset, $value)
207 207
     {
208 208
         if (!$value instanceof Field) {
209
-            throw new \InvalidArgumentException('Passed value must be of type ' . Field::class);
209
+            throw new \InvalidArgumentException('Passed value must be of type '.Field::class);
210 210
         }
211 211
 
212 212
         $this->fields[$offset] = $value;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
     private function validateFields(array $fields)
238 238
     {
239
-        array_map(function (Field $field) {
239
+        array_map(function(Field $field) {
240 240
         }, $fields);
241 241
     }
242 242
 
Please login to merge, or discard this patch.