@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | $permission = 'update-page'; |
| 65 | 65 | |
| 66 | - if (in_array($verb, ['index','show'])) { |
|
| 66 | + if (in_array($verb, ['index', 'show'])) { |
|
| 67 | 67 | $permission = 'view-page'; |
| 68 | - } elseif (in_array($verb, ['create','store'])) { |
|
| 68 | + } elseif (in_array($verb, ['create', 'store'])) { |
|
| 69 | 69 | $permission = 'create-page'; |
| 70 | 70 | } elseif (in_array($verb, ['delete'])) { |
| 71 | 71 | $permission = 'delete-page'; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if (! auth()->guard('chief')->user()->hasPermissionTo($permission)) { |
|
| 74 | + if (!auth()->guard('chief')->user()->hasPermissionTo($permission)) { |
|
| 75 | 75 | throw NotAllowedManagerRoute::notAllowedPermission($permission, $this); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | public function fieldArrangement($key = null): FieldArrangement |
| 134 | 134 | { |
| 135 | 135 | if ($key == 'create') { |
| 136 | - return new FieldArrangement($this->fieldsWithAssistantFields()->filterBy(function ($field) { |
|
| 136 | + return new FieldArrangement($this->fieldsWithAssistantFields()->filterBy(function($field) { |
|
| 137 | 137 | return in_array($field->key, ['title']); |
| 138 | 138 | })); |
| 139 | 139 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | public function saveFields(Request $request) |
| 166 | 166 | { |
| 167 | 167 | // Store the morph_key upon creation |
| 168 | - if ($this->model instanceof MorphableContract && ! $this->model->morph_key) { |
|
| 168 | + if ($this->model instanceof MorphableContract && !$this->model->morph_key) { |
|
| 169 | 169 | $this->model->morph_key = $this->model->morphKey(); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | if (is_array_empty($translation)) { |
| 211 | 211 | |
| 212 | 212 | // Nullify all values |
| 213 | - $trans[$locale] = array_map(function ($value) { |
|
| 213 | + $trans[$locale] = array_map(function($value) { |
|
| 214 | 214 | return null; |
| 215 | 215 | }, $translation); |
| 216 | 216 | continue; |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | { |
| 90 | 90 | $transitions = []; |
| 91 | 91 | |
| 92 | - foreach($this->transitions as $transitionKey => $transition){ |
|
| 92 | + foreach ($this->transitions as $transitionKey => $transition) { |
|
| 93 | 93 | if (false !== array_search($this->statefulContract->state(), $transition['from'])) { |
| 94 | 94 | $transitions[] = $transitionKey; |
| 95 | 95 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | { |
| 29 | 29 | $class = $this->pageState->isOnline() ? 'text-success' : 'text-warning'; |
| 30 | 30 | |
| 31 | - return '<span class="inline-xs stack-s '.$class.'">' . $this->stateAsLabel() . '</span>'; |
|
| 31 | + return '<span class="inline-xs stack-s '.$class.'">'.$this->stateAsLabel().'</span>'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | DB::beginTransaction(); |
| 22 | 22 | |
| 23 | 23 | // For stateful transitions we will apply this deletion as a state |
| 24 | - if($model instanceof StatefulContract) { |
|
| 24 | + if ($model instanceof StatefulContract) { |
|
| 25 | 25 | (new PageState($model))->apply('delete'); |
| 26 | 26 | $model->save(); |
| 27 | 27 | } |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | Relation::deleteRelationsOf($model->getMorphClass(), $model->id); |
| 30 | 30 | |
| 31 | 31 | // Mark the slug as deleted to avoid any conflict with newly created modules with the same slug. |
| 32 | - if($model instanceof Module) { |
|
| 32 | + if ($model instanceof Module) { |
|
| 33 | 33 | $model->update([ |
| 34 | - 'slug' => $model->slug . $this->appendDeleteMarker(), |
|
| 34 | + 'slug' => $model->slug.$this->appendDeleteMarker(), |
|
| 35 | 35 | ]); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if($model instanceof ProvidesUrl){ |
|
| 38 | + if ($model instanceof ProvidesUrl) { |
|
| 39 | 39 | UrlRecord::getByModel($model)->each->delete(); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($model instanceof Page){ |
|
| 42 | + if ($model instanceof Page) { |
|
| 43 | 43 | Module::where('page_id', $model->id)->delete(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -58,6 +58,6 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private function appendDeleteMarker(): string |
| 60 | 60 | { |
| 61 | - return '_DELETED_' . time(); |
|
| 61 | + return '_DELETED_'.time(); |
|
| 62 | 62 | } |
| 63 | 63 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function scopeUnarchived($query) |
| 25 | 25 | { |
| 26 | - $query->withoutGlobalScope(ArchiveScope::class)->where('current_state','<>', PageState::ARCHIVED); |
|
| 26 | + $query->withoutGlobalScope(ArchiveScope::class)->where('current_state', '<>', PageState::ARCHIVED); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function scopeWithArchived($query) |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Thinktomorrow\Chief\States\Archivable; |
| 6 | 6 | |
@@ -13,6 +13,6 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | public function apply(Builder $builder, Model $model) |
| 15 | 15 | { |
| 16 | - $builder->where('current_state','<>', PageState::ARCHIVED); |
|
| 16 | + $builder->where('current_state', '<>', PageState::ARCHIVED); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $this->manager = $manager; |
| 34 | 34 | $this->model = $manager->model(); |
| 35 | 35 | |
| 36 | - if(!$this->model instanceof StatefulContract){ |
|
| 36 | + if (!$this->model instanceof StatefulContract) { |
|
| 37 | 37 | throw new \InvalidArgumentException('PublishAssistant requires the model to implement the StatefulContract.'); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function findAll(): Collection |
| 76 | 76 | { |
| 77 | - return $this->model->published()->get()->map(function ($model) { |
|
| 77 | + return $this->model->published()->get()->map(function($model) { |
|
| 78 | 78 | return $this->managers->findByModel($model); |
| 79 | 79 | }); |
| 80 | 80 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | private function guard($verb): Assistant |
| 98 | 98 | { |
| 99 | - if (! $this->can($verb)) { |
|
| 99 | + if (!$this->can($verb)) { |
|
| 100 | 100 | NotAllowedManagerRoute::notAllowedVerb($verb, $this->manager); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | $class = 'text-warning'; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $statusAsLabel = '<span class="font-bold '. $class .'"><em>' . $label . '</em></span>'; |
|
| 124 | + $statusAsLabel = '<span class="font-bold '.$class.'"><em>'.$label.'</em></span>'; |
|
| 125 | 125 | |
| 126 | 126 | if (!$plain && $this->hasPreviewUrl()) { |
| 127 | - $statusAsLabel = '<a href="'.$this->previewUrl().'" target="_blank">'. $statusAsLabel .'</a>'; |
|
| 127 | + $statusAsLabel = '<a href="'.$this->previewUrl().'" target="_blank">'.$statusAsLabel.'</a>'; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | return $statusAsLabel; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $registrations = collect($this->register->filterByTag($tag)->all()); |
| 52 | 52 | |
| 53 | - return $registrations->map(function ($registration) { |
|
| 53 | + return $registrations->map(function($registration) { |
|
| 54 | 54 | return $this->instance($registration); |
| 55 | 55 | }); |
| 56 | 56 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $registrations = collect($this->register->filterByTag($tag)->all()); |
| 67 | 67 | |
| 68 | - return $registrations->map(function ($registration) { |
|
| 68 | + return $registrations->map(function($registration) { |
|
| 69 | 69 | return $this->instance($registration)->details(); |
| 70 | 70 | }); |
| 71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | //return array with group name and values |
| 77 | 77 | $grouped = []; |
| 78 | 78 | |
| 79 | - $managers = $managers->map(function (Manager $item) { |
|
| 79 | + $managers = $managers->map(function(Manager $item) { |
|
| 80 | 80 | return [ |
| 81 | 81 | 'id' => $item->details()->id, |
| 82 | 82 | 'group' => $item->details()->plural, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $registrations = collect($this->register->all()); |
| 92 | 92 | |
| 93 | - return $registrations->map(function ($registration) { |
|
| 93 | + return $registrations->map(function($registration) { |
|
| 94 | 94 | return $this->instance($registration); |
| 95 | 95 | }); |
| 96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $assistants = collect(); |
| 101 | 101 | |
| 102 | - foreach($this->all() as $manager) { |
|
| 102 | + foreach ($this->all() as $manager) { |
|
| 103 | 103 | $assistants = $assistants->merge($manager->assistants(false)); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | public function anyRegisteredByTag($tag) |
| 110 | 110 | { |
| 111 | - return ! empty($this->register->filterByTag($tag)->all()); |
|
| 111 | + return !empty($this->register->filterByTag($tag)->all()); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | $this->manager = $manager; |
| 21 | 21 | $this->model = $manager->model(); |
| 22 | 22 | |
| 23 | - if(!$this->model instanceof StatefulContract){ |
|
| 24 | - throw new \InvalidArgumentException(static::class . ' requires the model to implement the ' . StatefulContract::class); |
|
| 23 | + if (!$this->model instanceof StatefulContract) { |
|
| 24 | + throw new \InvalidArgumentException(static::class.' requires the model to implement the '.StatefulContract::class); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function guard($verb): Assistant |
| 38 | 38 | { |
| 39 | - if (! $this->can($verb)) { |
|
| 39 | + if (!$this->can($verb)) { |
|
| 40 | 40 | NotAllowedManagerRoute::notAllowedVerb($verb, $this->manager); |
| 41 | 41 | } |
| 42 | 42 | |