@@ -21,7 +21,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -63,7 +63,9 @@ |
||
| 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 |
@@ -20,15 +20,15 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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) |
@@ -28,7 +28,9 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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) |
@@ -25,14 +25,18 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -21,21 +21,21 @@ discard block |
||
| 21 | 21 | public function routesPublishAssistant(): array |
| 22 | 22 | { |
| 23 | 23 | return [ |
| 24 | - ManagedRoute::post('publish','publish/{id}'), |
|
| 25 | - ManagedRoute::post('unpublish','unpublish/{id}'), |
|
| 24 | + ManagedRoute::post('publish', 'publish/{id}'), |
|
| 25 | + ManagedRoute::post('unpublish', 'unpublish/{id}'), |
|
| 26 | 26 | ]; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function routePublishAssistant(string $action, $model = null, ...$parameters): ?string |
| 30 | 30 | { |
| 31 | - if(!$this->canPublishAssistant($action, $model)) return null; |
|
| 31 | + if (!$this->canPublishAssistant($action, $model)) return null; |
|
| 32 | 32 | |
| 33 | 33 | return $this->generateRoute($action, $model, ...$parameters); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function canPublishAssistant(string $action, $model = null): bool |
| 37 | 37 | { |
| 38 | - if(!in_array($action, ['publish', 'unpublish'])) return false; |
|
| 38 | + if (!in_array($action, ['publish', 'unpublish'])) return false; |
|
| 39 | 39 | |
| 40 | 40 | try { |
| 41 | 41 | $this->authorize('update-page'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
| 46 | + if (!$model || !$model instanceof StatefulContract) return false; |
|
| 47 | 47 | |
| 48 | 48 | return PageState::make($model)->can($action); |
| 49 | 49 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $modelClass = $this->managedModelClass(); |
| 54 | 54 | if (Schema::hasColumn((new $modelClass)->getTable(), 'published_at')) { |
| 55 | 55 | return new Filters([ |
| 56 | - HiddenFilter::make('publish', function ($query) { |
|
| 56 | + HiddenFilter::make('publish', function($query) { |
|
| 57 | 57 | return $query->orderBy('published_at', 'DESC'); |
| 58 | 58 | }), |
| 59 | 59 | ]); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | Audit::activity()->performedOn($model)->log('published'); |
| 74 | 74 | |
| 75 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is online geplaatst.'); |
|
| 75 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is online geplaatst.'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function unpublish(Request $request, $id) |
@@ -85,6 +85,6 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | Audit::activity()->performedOn($model)->log('unpublished'); |
| 87 | 87 | |
| 88 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is offline gehaald.'); |
|
| 88 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is offline gehaald.'); |
|
| 89 | 89 | } |
| 90 | 90 | } |
@@ -39,7 +39,9 @@ discard block |
||
| 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 |
||
| 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'])) { |
@@ -39,7 +39,7 @@ discard block |
||
| 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 | |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if(in_array($action, ['index', 'create', 'store'])) return true; |
|
| 61 | + if (in_array($action, ['index', 'create', 'store'])) return true; |
|
| 62 | 62 | |
| 63 | - if(!$model || !$model instanceof StatefulContract) return true; |
|
| 63 | + if (!$model || !$model instanceof StatefulContract) return true; |
|
| 64 | 64 | |
| 65 | 65 | // Model cannot be in deleted state for editing purposes. |
| 66 | - if(in_array($action, ['edit', 'update'])) { |
|
| 66 | + if (in_array($action, ['edit', 'update'])) { |
|
| 67 | 67 | return !($model->stateOf(PageState::KEY) == PageState::DELETED); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | $filters = new Filters(); |
| 100 | 100 | |
| 101 | - foreach(DiscoverTraitMethods::belongingTo(static::class, 'filters') as $method) { |
|
| 101 | + foreach (DiscoverTraitMethods::belongingTo(static::class, 'filters') as $method) { |
|
| 102 | 102 | $filters = $filters->merge($this->$method()); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | // if model has no timestamps, updated_at doesn't exist |
| 115 | 115 | if ((new $modelClass)->timestamps) { |
| 116 | - return $filters->add(HiddenFilter::make('updated', function ($query) { |
|
| 116 | + return $filters->add(HiddenFilter::make('updated', function($query) { |
|
| 117 | 117 | return $query->orderBy('updated_at', 'DESC'); |
| 118 | 118 | })); |
| 119 | 119 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $model->saveFields($model->fields()->notTagged('edit'), $request->all(), $request->allFiles()); |
| 149 | 149 | |
| 150 | 150 | return redirect()->to($this->route('edit', $model)) |
| 151 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is toegevoegd'); |
|
| 151 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is toegevoegd'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public function edit(Request $request, $id) |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $model->saveFields($model->fields()->notTagged('create'), $request->all(), $request->allFiles()); |
| 176 | 176 | |
| 177 | 177 | return redirect()->to($this->route('index')) |
| 178 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> <a href="' . $this->route('edit', $model) . '">' . $model->adminLabel('title') . '</a> is aangepast'); |
|
| 178 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> <a href="'.$this->route('edit', $model).'">'.$model->adminLabel('title').'</a> is aangepast'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | public function delete(Request $request, $id) |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | $this->guard('delete', $model); |
| 186 | 186 | |
| 187 | 187 | if ($request->get('deleteconfirmation') !== 'DELETE') { |
| 188 | - return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.'); |
|
| 188 | + return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.'); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | app(DeleteModel::class)->handle($model); |
| 192 | 192 | |
| 193 | 193 | return redirect()->to($this->route('index')) |
| 194 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is verwijderd.'); |
|
| 194 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is verwijderd.'); |
|
| 195 | 195 | } |
| 196 | 196 | } |
@@ -40,8 +40,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -53,13 +53,13 @@ |
||
| 53 | 53 | |
| 54 | 54 | if ($child instanceof Module && $child->isPageSpecific()) { |
| 55 | 55 | $duplicatedChild = $child::create([ |
| 56 | - 'slug' => $targetModel->title ? $targetModel->title . '-' . $child->slug : $child->slug . '-copy', |
|
| 56 | + 'slug' => $targetModel->title ? $targetModel->title.'-'.$child->slug : $child->slug.'-copy', |
|
| 57 | 57 | 'owner_id' => $targetModel->id, |
| 58 | 58 | 'owner_type' => $targetModel->getMorphClass() |
| 59 | 59 | ]); |
| 60 | 60 | |
| 61 | 61 | $this->moduleTemplateApplicator->handle($child, $duplicatedChild); |
| 62 | - } else { |
|
| 62 | + }else { |
|
| 63 | 63 | $duplicatedChild = $child; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function handle($sourceModel, $targetModel): void |
| 24 | 24 | { |
| 25 | - if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return; |
|
| 25 | + if (!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return; |
|
| 26 | 26 | |
| 27 | 27 | $copiedContext = ContextModel::createForOwner($targetModel); |
| 28 | 28 | |
| 29 | 29 | /** @var FragmentModel $fragment */ |
| 30 | - foreach($context->fragments as $fragment) { |
|
| 30 | + foreach ($context->fragments as $fragment) { |
|
| 31 | 31 | $copiedFragment = $fragment->replicate(['context_id']); |
| 32 | 32 | $copiedFragment->id = $this->fragmentRepository->nextId(); |
| 33 | 33 | $copiedFragment->context_id = $copiedContext->id; |
@@ -22,7 +22,9 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function handle($sourceModel, $targetModel): void |
| 24 | 24 | { |
| 25 | - if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return; |
|
| 25 | + if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) { |
|
| 26 | + return; |
|
| 27 | + } |
|
| 26 | 28 | |
| 27 | 29 | $copiedContext = ContextModel::createForOwner($targetModel); |
| 28 | 30 | |
@@ -31,18 +31,18 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function routeFragmentAssistant(string $action, $model = null, ...$parameters): ?string |
| 33 | 33 | { |
| 34 | - if(!in_array($action, ['fragment-edit','fragment-update','fragment-delete','fragment-create','fragment-store'])) { |
|
| 34 | + if (!in_array($action, ['fragment-edit', 'fragment-update', 'fragment-delete', 'fragment-create', 'fragment-store'])) { |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $modelKey = $this->managedModelClass()::managedModelKey(); |
| 39 | 39 | |
| 40 | - if(in_array($action, ['fragment-create', 'fragment-store'])) { |
|
| 40 | + if (in_array($action, ['fragment-create', 'fragment-store'])) { |
|
| 41 | 41 | if (!$model || !$model instanceof FragmentsOwner) { |
| 42 | 42 | throw new \Exception('Fragment route definition for '.$action.' requires the owning Model as second argument.'); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - return route('chief.' . $modelKey . '.' . $action, array_merge([ |
|
| 45 | + return route('chief.'.$modelKey.'.'.$action, array_merge([ |
|
| 46 | 46 | $model::managedModelKey(), |
| 47 | 47 | $model->modelReference()->id(), |
| 48 | 48 | ], $parameters)); |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | throw new \Exception('Fragment route definition for '.$action.' requires the fragment model as second argument.'); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - return route('chief.' . $modelKey . '.' . $action, $model->fragmentModel()->id); |
|
| 55 | + return route('chief.'.$modelKey.'.'.$action, $model->fragmentModel()->id); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function canFragmentAssistant(string $action, $model = null): bool |
| 59 | 59 | { |
| 60 | - return in_array($action, ['fragment-edit','fragment-update','fragment-delete','fragment-create','fragment-store']); |
|
| 60 | + return in_array($action, ['fragment-edit', 'fragment-update', 'fragment-delete', 'fragment-create', 'fragment-store']); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function fragmentCreate(Request $request, string $ownerKey, $ownerId) |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | $model = $this->managedModelClass()::findOrFail($id); |
| 145 | 145 | |
| 146 | 146 | if ($request->get('deleteconfirmation') !== 'DELETE') { |
| 147 | - return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.'); |
|
| 147 | + return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.'); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | app(DeleteModel::class)->handle($model); |
| 151 | 151 | |
| 152 | 152 | return redirect()->to($this->route('index')) |
| 153 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is verwijderd.'); |
|
| 153 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is verwijderd.'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | private function owner(string $ownerKey, $ownerId): FragmentsOwner |