Test Setup Failed
Push — a-simpler-manager ( 19ed38...0806fa )
by Ben
07:03
created
src/Site/Menu/Menu.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $types = config('chief.menus', []);
30 30
 
31
-        return collect($types)->map(function ($menu, $key) {
31
+        return collect($types)->map(function($menu, $key) {
32 32
             return new static($key, $menu['label'], $menu['view']);
33 33
         });
34 34
     }
35 35
 
36 36
     public static function find($key): ?self
37 37
     {
38
-        return static::all()->filter(function ($menu) use ($key) {
38
+        return static::all()->filter(function($menu) use ($key) {
39 39
             return $menu->key() == $key;
40 40
         })->first();
41 41
     }
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $menu = [];
86 86
 
87
-        $this->items()->each(function ($item) use (&$menu) {
87
+        $this->items()->each(function($item) use (&$menu) {
88 88
             $menu[] = sprintf('<li><a href="%s">%s</a></li>', $item->url, $item->label);
89 89
         });
90 90
 
91
-        return '<ul>' . implode('', $menu) . '</ul>';
91
+        return '<ul>'.implode('', $menu).'</ul>';
92 92
     }
93 93
 }
Please login to merge, or discard this patch.
src/Site/Urls/Controllers/LinksController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,19 +20,19 @@
 block discarded – undo
20 20
     public function update(Request $request)
21 21
     {
22 22
         /** @var ProvidesUrl|Model $model */
23
-        $model = (new ModelReference($request->modelClass, (int) $request->modelId))->instance();
23
+        $model = (new ModelReference($request->modelClass, (int)$request->modelId))->instance();
24 24
 
25 25
         $this->validate($request, ['links' => [
26
-            'array', 'min:1', new UniqueUrlSlugRule($model, $model),], [], ['links.*' => 'taalspecifieke link']
26
+            'array', 'min:1', new UniqueUrlSlugRule($model, $model), ], [], ['links.*' => 'taalspecifieke link']
27 27
         ]);
28 28
 
29 29
         (new SaveUrlSlugs())->handle($model, $request->input('links', []));
30 30
 
31 31
         // Push update to homepage setting value
32 32
         // TODO: we should just fetch the homepages and push that instead...
33
-        UrlRecord::getByModel($model)->reject(function ($record) {
33
+        UrlRecord::getByModel($model)->reject(function($record) {
34 34
             return ($record->isRedirect() || !$record->isHomepage());
35
-        })->each(function ($record) {
35
+        })->each(function($record) {
36 36
             app(ChangeHomepage::class)->onUrlChanged($record);
37 37
         });
38 38
 
Please login to merge, or discard this patch.
src/Site/Urls/Form/LinkForm.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         return new static($model, \Thinktomorrow\Chief\Site\Urls\UrlRecord::getByModel($model)
24 24
             ->groupBy('locale')
25
-            ->map(function ($records) {
25
+            ->map(function($records) {
26 26
                 return $records->sortBy('redirect_id')->sortByDesc('created_at');
27 27
             }));
28 28
     }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             $currentRecord = $this->urlRecords->get($locale, collect())->reject->isRedirect()->first();
55 55
 
56 56
             $values[$locale] = (object)[
57
-                'host'         => $this->model->resolveUrl($locale, $this->model->baseUrlSegment($locale)) . '/',
57
+                'host'         => $this->model->resolveUrl($locale, $this->model->baseUrlSegment($locale)).'/',
58 58
                 'fixedSegment' => $this->model->baseUrlSegment($locale),
59 59
                 'value'        => $currentRecord
60 60
                     ? $this->rawSlugValue($currentRecord->slug, $this->model->baseUrlSegment($locale))
Please login to merge, or discard this patch.
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.