@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function routeModulesAssistant(string $action, $model = null, ...$parameters): ?string |
| 32 | 32 | { |
| 33 | - if(!in_array($action, ['modules-index','modules-edit','modules-update','modules-delete','modules-create','modules-store'])) return null; |
|
| 33 | + if (!in_array($action, ['modules-index', 'modules-edit', 'modules-update', 'modules-delete', 'modules-create', 'modules-store'])) return null; |
|
| 34 | 34 | |
| 35 | - if(count($parameters) < 1 || ! reset($parameters) instanceof ActsAsChild) { |
|
| 35 | + if (count($parameters) < 1 || !reset($parameters) instanceof ActsAsChild) { |
|
| 36 | 36 | throw new \InvalidArgumentException('Missing arguments. Modules route definition requires two parameters: parent model and module model. '); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $modules = $parent->children(); |
| 52 | 52 | |
| 53 | 53 | // Add their respective manager per class |
| 54 | - $moduleManagers = $modules->groupBy(function ($child) { |
|
| 54 | + $moduleManagers = $modules->groupBy(function($child) { |
|
| 55 | 55 | return get_class($child); |
| 56 | - })->map(function ($child, $class) { |
|
| 56 | + })->map(function($child, $class) { |
|
| 57 | 57 | return app(ModelToManagerMap::class)->find($class); |
| 58 | 58 | }); |
| 59 | 59 | |
@@ -30,7 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function routeModulesAssistant(string $action, $model = null, ...$parameters): ?string |
| 32 | 32 | { |
| 33 | - if(!in_array($action, ['modules-index','modules-edit','modules-update','modules-delete','modules-create','modules-store'])) return null; |
|
| 33 | + if(!in_array($action, ['modules-index','modules-edit','modules-update','modules-delete','modules-create','modules-store'])) { |
|
| 34 | + return null; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | if(count($parameters) < 1 || ! reset($parameters) instanceof ActsAsChild) { |
| 36 | 38 | throw new \InvalidArgumentException('Missing arguments. Modules route definition requires two parameters: parent model and module model. '); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function routeModuleCrudAssistant(string $action, $model = null, ...$parameters): ?string |
| 33 | 33 | { |
| 34 | - if(!in_array($action, ['create','store'])) return null; |
|
| 34 | + if (!in_array($action, ['create', 'store'])) return null; |
|
| 35 | 35 | |
| 36 | 36 | return $this->generateRoute($action, $model, ... $parameters); |
| 37 | 37 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $model->saveFields($model->fields()->tagged('create'), $request->all(), $request->allFiles()); |
| 61 | 61 | |
| 62 | 62 | return redirect()->to($this->route('edit', $model)) |
| 63 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is toegevoegd'); |
|
| 63 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is toegevoegd'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function edit($id) |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | return view('chief::back.managers.edit', [ |
| 76 | 76 | 'model' => $model, |
| 77 | 77 | 'managerViewModel' => $this->managerViewModel(), |
| 78 | - 'fields' => $model->fields()->map(function (Field $field) use ($model) { |
|
| 78 | + 'fields' => $model->fields()->map(function(Field $field) use ($model) { |
|
| 79 | 79 | // TODO refactor so render method of field takes model and managerViewModel as arguments. |
| 80 | 80 | return $field->model($model) |
| 81 | 81 | ->viewData(['managerViewModel' => $this->managerViewModel()]); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $model->saveFields($model->fields(), $request->all(), $request->allFiles()); |
| 96 | 96 | |
| 97 | 97 | return redirect()->to($this->route('edit', $model)) |
| 98 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is aangepast'); |
|
| 98 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is aangepast'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function delete($id, Request $request) |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | $model = static::managedModelClass()::findOrFail($id); |
| 106 | 106 | |
| 107 | 107 | if ($request->get('deleteconfirmation') !== 'DELETE') { |
| 108 | - return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.'); |
|
| 108 | + return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.'); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | app(DeleteManagedModel::class)->handle($model); |
| 112 | 112 | |
| 113 | 113 | return redirect()->to($this->route('index')) |
| 114 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is verwijderd.'); |
|
| 114 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is verwijderd.'); |
|
| 115 | 115 | } |
| 116 | 116 | } |
@@ -31,7 +31,9 @@ |
||
| 31 | 31 | |
| 32 | 32 | public function routeModuleCrudAssistant(string $action, $model = null, ...$parameters): ?string |
| 33 | 33 | { |
| 34 | - if(!in_array($action, ['create','store'])) return null; |
|
| 34 | + if(!in_array($action, ['create','store'])) { |
|
| 35 | + return null; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | return $this->generateRoute($action, $model, ... $parameters); |
| 37 | 39 | } |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | // TODO: how to assign for pagebuilder?? with tag, via the chief relations config or is this default |
| 37 | 37 | $moduleManagerClasses = $this->registeredManagers->tagged('module')->get(); |
| 38 | 38 | |
| 39 | - $managers = collect(array_map(function($moduleManagerClass){ |
|
| 39 | + $managers = collect(array_map(function($moduleManagerClass) { |
|
| 40 | 40 | return app($moduleManagerClass); |
| 41 | 41 | }, $moduleManagerClasses)); |
| 42 | 42 | |
| 43 | 43 | return $managers |
| 44 | - ->reject(function($manager){ return !$manager->can('create'); }) |
|
| 44 | + ->reject(function($manager) { return !$manager->can('create'); }) |
|
| 45 | 45 | ->map(function($manager) { |
| 46 | 46 | return [ |
| 47 | 47 | 'label' => $manager->adminLabel('page_title'), |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | // Get the modules that are set to be shareable. |
| 57 | 57 | $moduleManagerClasses = $this->shareableModules(); |
| 58 | 58 | |
| 59 | - $managers = collect(array_map(function($moduleManagerClass){ |
|
| 59 | + $managers = collect(array_map(function($moduleManagerClass) { |
|
| 60 | 60 | return app($moduleManagerClass); |
| 61 | 61 | }, $moduleManagerClasses)); |
| 62 | 62 | |
| 63 | 63 | return $managers |
| 64 | - ->reject(function($manager){ return !$manager->can('create-shared'); }) |
|
| 65 | - ->map(function($manager){ |
|
| 64 | + ->reject(function($manager) { return !$manager->can('create-shared'); }) |
|
| 65 | + ->map(function($manager) { |
|
| 66 | 66 | return [ |
| 67 | 67 | 'label' => $manager->adminLabel('page_title'), |
| 68 | 68 | 'value' => $manager->route('create-shared') |
@@ -35,6 +35,6 @@ |
||
| 35 | 35 | /** @inheritdoc */ |
| 36 | 36 | public function baseUrlSegment(string $locale = null): string |
| 37 | 37 | { |
| 38 | - return BaseUrlSegment::find(isset(static::$baseUrlSegment) ? (array) static::$baseUrlSegment : [], $locale); |
|
| 38 | + return BaseUrlSegment::find(isset(static::$baseUrlSegment) ? (array)static::$baseUrlSegment : [], $locale); |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | public static function find(array $segments, string $locale = null) |
| 12 | 12 | { |
| 13 | - if(count($segments) < 1) return '/'; |
|
| 14 | - if(count($segments) == 1) return reset($segments); |
|
| 13 | + if (count($segments) < 1) return '/'; |
|
| 14 | + if (count($segments) == 1) return reset($segments); |
|
| 15 | 15 | |
| 16 | 16 | // Localized value |
| 17 | 17 | if (($key = $locale ?? app()->getlocale()) && isset($segments[$key])) return $segments[$key]; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public static function prepend(ProvidesUrl $model, string $slug, $locale): string |
| 33 | 33 | { |
| 34 | - $slugWithBaseSegment = $model->baseUrlSegment($locale) . '/' . $slug; |
|
| 34 | + $slugWithBaseSegment = $model->baseUrlSegment($locale).'/'.$slug; |
|
| 35 | 35 | $slugWithBaseSegment = trim($slugWithBaseSegment, '/'); |
| 36 | 36 | |
| 37 | 37 | // If slug with base segment is empty string, it means that the passed slug was probably a "/" character. |
@@ -10,14 +10,22 @@ |
||
| 10 | 10 | { |
| 11 | 11 | public static function find(array $segments, string $locale = null) |
| 12 | 12 | { |
| 13 | - if(count($segments) < 1) return '/'; |
|
| 14 | - if(count($segments) == 1) return reset($segments); |
|
| 13 | + if(count($segments) < 1) { |
|
| 14 | + return '/'; |
|
| 15 | + } |
|
| 16 | + if(count($segments) == 1) { |
|
| 17 | + return reset($segments); |
|
| 18 | + } |
|
| 15 | 19 | |
| 16 | 20 | // Localized value |
| 17 | - if (($key = $locale ?? app()->getlocale()) && isset($segments[$key])) return $segments[$key]; |
|
| 21 | + if (($key = $locale ?? app()->getlocale()) && isset($segments[$key])) { |
|
| 22 | + return $segments[$key]; |
|
| 23 | + } |
|
| 18 | 24 | |
| 19 | 25 | // Fallback localized value |
| 20 | - if (($fallback_locale = config('app.fallback_locale')) && isset($segments[$fallback_locale])) return $segments[$fallback_locale]; |
|
| 26 | + if (($fallback_locale = config('app.fallback_locale')) && isset($segments[$fallback_locale])) { |
|
| 27 | + return $segments[$fallback_locale]; |
|
| 28 | + } |
|
| 21 | 29 | |
| 22 | 30 | // Fallback to first entry |
| 23 | 31 | return reset($segments); |
@@ -44,14 +44,14 @@ |
||
| 44 | 44 | |
| 45 | 45 | private function statusAsLabel(): string |
| 46 | 46 | { |
| 47 | - if(!$this instanceof ProvidesUrl) return ''; |
|
| 47 | + if (!$this instanceof ProvidesUrl) return ''; |
|
| 48 | 48 | |
| 49 | 49 | if ($this->current_status === PageState::PUBLISHED) { |
| 50 | - return '<a href="' . $this->url() . '" target="_blank"><em>online</em></a>'; |
|
| 50 | + return '<a href="'.$this->url().'" target="_blank"><em>online</em></a>'; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if ($this->current_status === PageState::DRAFT) { |
| 54 | - return '<a href="' . $this->url() . '" target="_blank" class="text-error"><em>offline</em></a>'; |
|
| 54 | + return '<a href="'.$this->url().'" target="_blank" class="text-error"><em>offline</em></a>'; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | if ($this->current_status === PageState::ARCHIVED) { |
@@ -44,7 +44,9 @@ |
||
| 44 | 44 | |
| 45 | 45 | private function statusAsLabel(): string |
| 46 | 46 | { |
| 47 | - if(!$this instanceof ProvidesUrl) return ''; |
|
| 47 | + if(!$this instanceof ProvidesUrl) { |
|
| 48 | + return ''; |
|
| 49 | + } |
|
| 48 | 50 | |
| 49 | 51 | if ($this->current_status === PageState::PUBLISHED) { |
| 50 | 52 | return '<a href="' . $this->url() . '" target="_blank"><em>online</em></a>'; |