Test Setup Failed
Push — a-simpler-manager ( cdafdc...332d14 )
by Ben
07:32
created
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/CrudAssistant.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  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'])) return false;
43 43
 
44 44
         try {
45 45
             $this->authorize($action);
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
             return false;
48 48
         }
49 49
 
50
-        if(in_array($action, ['index', 'create', 'store'])) return true;
50
+        if (in_array($action, ['index', 'create', 'store'])) return true;
51 51
 
52
-        if(!$model || !$model instanceof StatefulContract) return false;
52
+        if (!$model || !$model instanceof StatefulContract) return false;
53 53
 
54 54
         // Model cannot be in deleted state for editing purposes.
55
-        if(in_array($action, ['edit', 'update', 'delete']) && $model->stateOf(PageState::KEY) == PageState::DELETED) return false;
55
+        if (in_array($action, ['edit', 'update', 'delete']) && $model->stateOf(PageState::KEY) == PageState::DELETED) return false;
56 56
 
57 57
         return PageState::make($model)->can($action);
58 58
     }
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
         // Default sorted by publish date
110 110
         $modelClass = $this->managedModelClass();
111 111
         if (Schema::hasColumn((new $modelClass)->getTable(), 'published_at')) {
112
-            $filters = $filters->add(HiddenFilter::make('publish', function ($query) {
112
+            $filters = $filters->add(HiddenFilter::make('publish', function($query) {
113 113
                 return $query->orderBy('published_at', 'DESC');
114 114
             }));
115 115
         }
116 116
 
117 117
         // if model has no timestamps, updated_at doesn't exist
118 118
         if ((new $modelClass)->timestamps) {
119
-            $filters = $filters->add(HiddenFilter::make('updated', function ($query) {
119
+            $filters = $filters->add(HiddenFilter::make('updated', function($query) {
120 120
                 return $query->orderBy('updated_at', 'DESC');
121 121
             }));
122 122
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $model->saveFields($model->fields()->tagged('create'), $request->all(), $request->allFiles());
151 151
 
152 152
         return redirect()->to($this->route('edit', $model))
153
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is toegevoegd');
153
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is toegevoegd');
154 154
     }
155 155
 
156 156
     public function edit(Request $request, $id)
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $model->saveFields($model->fields(), $request->all(), $request->allFiles());
180 180
 
181 181
         return redirect()->to($this->route('index'))
182
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  <a href="' . $this->route('edit', $model) . '">' . $model->adminLabel('title') . '</a> is aangepast');
182
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  <a href="'.$this->route('edit', $model).'">'.$model->adminLabel('title').'</a> is aangepast');
183 183
     }
184 184
 
185 185
     public function delete(Request $request, $id)
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
         $this->guard('delete', $model);
190 190
 
191 191
         if ($request->get('deleteconfirmation') !== 'DELETE') {
192
-            return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.');
192
+            return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.');
193 193
         }
194 194
 
195 195
         app(DeleteManagedModel::class)->handle($model);
196 196
 
197 197
         return redirect()->to($this->route('index'))
198
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is verwijderd.');
198
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is verwijderd.');
199 199
     }
200 200
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 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
             $this->authorize($action);
@@ -47,12 +49,18 @@  discard block
 block discarded – undo
47 49
             return false;
48 50
         }
49 51
 
50
-        if(in_array($action, ['index', 'create', 'store'])) return true;
52
+        if(in_array($action, ['index', 'create', 'store'])) {
53
+            return true;
54
+        }
51 55
 
52
-        if(!$model || !$model instanceof StatefulContract) return false;
56
+        if(!$model || !$model instanceof StatefulContract) {
57
+            return false;
58
+        }
53 59
 
54 60
         // Model cannot be in deleted state for editing purposes.
55
-        if(in_array($action, ['edit', 'update', 'delete']) && $model->stateOf(PageState::KEY) == PageState::DELETED) return false;
61
+        if(in_array($action, ['edit', 'update', 'delete']) && $model->stateOf(PageState::KEY) == PageState::DELETED) {
62
+            return false;
63
+        }
56 64
 
57 65
         return PageState::make($model)->can($action);
58 66
     }
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.