@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | // Set required paths |
| 39 | 39 | $this->dirs = ['base' => $this->settings['base_path'] ?? base_path()]; |
| 40 | - $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'] .'/'. config('thinktomorrow.chief.domain.path', 'src'); |
|
| 41 | - $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'] . '/resources/views'; |
|
| 42 | - $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'] . '/app/Http/Controllers'; |
|
| 43 | - $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'] . '/routes/web.php'; |
|
| 40 | + $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'].'/'.config('thinktomorrow.chief.domain.path', 'src'); |
|
| 41 | + $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'].'/resources/views'; |
|
| 42 | + $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'].'/app/Http/Controllers'; |
|
| 43 | + $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'].'/routes/web.php'; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public function handle() |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | private function publishModel() |
| 63 | 63 | { |
| 64 | 64 | $this->publishFile( |
| 65 | - __DIR__ . '/stubs/model.php.stub', |
|
| 66 | - $to = $this->dirs['model'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
| 65 | + __DIR__.'/stubs/model.php.stub', |
|
| 66 | + $to = $this->dirs['model'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
| 67 | 67 | 'model' |
| 68 | 68 | ); |
| 69 | 69 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | private function publishController() |
| 74 | 74 | { |
| 75 | 75 | $this->publishFile( |
| 76 | - __DIR__ . '/stubs/controller.php.stub', |
|
| 77 | - $to = $this->dirs['controller'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
| 76 | + __DIR__.'/stubs/controller.php.stub', |
|
| 77 | + $to = $this->dirs['controller'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
| 78 | 78 | 'controller' |
| 79 | 79 | ); |
| 80 | 80 | } |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | private function modelTraits() |
| 114 | 114 | { |
| 115 | 115 | return [ |
| 116 | - '\\' . Publishable::class, |
|
| 117 | - '\\' . Sortable::class, |
|
| 116 | + '\\'.Publishable::class, |
|
| 117 | + '\\'.Sortable::class, |
|
| 118 | 118 | 'q' => 'Proceed.', |
| 119 | 119 | ]; |
| 120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | protected function publishFile($from, $to, $type) |
| 130 | 130 | { |
| 131 | 131 | if ($this->filesystem->exists($to) && !$this->option('force')) { |
| 132 | - if (!$this->confirm('File [' . $to . '] already exists? Overwrite this file?')) { |
|
| 132 | + if (!$this->confirm('File ['.$to.'] already exists? Overwrite this file?')) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $to = str_replace($this->dirs['base'], '', realpath($to)); |
| 170 | 170 | |
| 171 | - $this->line('<info>Copied ' . $type . '</info> <comment>[' . $from . ']</comment> <info>To</info> <comment>[' . $to . ']</comment>'); |
|
| 171 | + $this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | protected function replacePlaceholders($content) |
@@ -187,16 +187,16 @@ discard block |
||
| 187 | 187 | private function generateImportStatements(): string |
| 188 | 188 | { |
| 189 | 189 | return collect(['\\'.Page::class]) |
| 190 | - ->map(function ($statement) { |
|
| 191 | - return 'use ' . $statement . ";\n "; |
|
| 190 | + ->map(function($statement) { |
|
| 191 | + return 'use '.$statement.";\n "; |
|
| 192 | 192 | })->implode(''); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | private function generateTraitStatements(): string |
| 196 | 196 | { |
| 197 | 197 | return collect($this->chosenTraits) |
| 198 | - ->map(function ($statement) { |
|
| 199 | - return 'use ' . $statement . ";\n "; |
|
| 198 | + ->map(function($statement) { |
|
| 199 | + return 'use '.$statement.";\n "; |
|
| 200 | 200 | })->implode(''); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | // We make an estimated guess based on the project name. At Think Tomorrow, we |
| 217 | 217 | // have a src folder which is PSR-4 namespaced by the project name itself. |
| 218 | - return str_replace('\\\\', '\\', ucfirst(config('thinktomorrow.chief.domain.namespace', 'App')).'\\'. ucfirst($this->plural)); |
|
| 218 | + return str_replace('\\\\', '\\', ucfirst(config('thinktomorrow.chief.domain.namespace', 'App')).'\\'.ucfirst($this->plural)); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | private function addToConfig($configKey, $value) |
@@ -35,12 +35,12 @@ |
||
| 35 | 35 | |
| 36 | 36 | public function toReference(): SetReference |
| 37 | 37 | { |
| 38 | - $reference = SetReference::all()->first(function ($setReference) { |
|
| 38 | + $reference = SetReference::all()->first(function($setReference) { |
|
| 39 | 39 | return $setReference->key() == $this->key; |
| 40 | 40 | }); |
| 41 | 41 | |
| 42 | 42 | if (!$reference) { |
| 43 | - throw new \Exception('No query set found by key ['. $this->key. ']. Make sure that this '.$this->key.' set is added to the chief.sets config array.'); |
|
| 43 | + throw new \Exception('No query set found by key ['.$this->key.']. Make sure that this '.$this->key.' set is added to the chief.sets config array.'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return $reference; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public static function rolesForSelect($includeDeveloperRole = false) |
| 20 | 20 | { |
| 21 | - $roles = $includeDeveloperRole ? static::all() : static::all()->reject(function ($role) { |
|
| 21 | + $roles = $includeDeveloperRole ? static::all() : static::all()->reject(function($role) { |
|
| 22 | 22 | return $role->name == 'developer'; |
| 23 | 23 | }); |
| 24 | 24 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function getPermissionsForIndex() |
| 41 | 41 | { |
| 42 | - $this->permissions->each(function ($permission) { |
|
| 42 | + $this->permissions->each(function($permission) { |
|
| 43 | 43 | $model = explode("_", $permission->name, 2)[1]; |
| 44 | 44 | $temp = $this->permission; |
| 45 | 45 | $temp[$model][] = explode("_", $permission->name, 2)[0]; |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | public function apply($value = null): Closure |
| 17 | 17 | { |
| 18 | - return $this->query && $this->query instanceof Closure ? $this->query : function ($query) { |
|
| 18 | + return $this->query && $this->query instanceof Closure ? $this->query : function($query) { |
|
| 19 | 19 | return $query; |
| 20 | 20 | }; |
| 21 | 21 | } |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Thinktomorrow\Chief\Fields\Types; |
| 5 | 5 | |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | |
| 65 | 65 | public function __toString() |
| 66 | 66 | { |
| 67 | - return (string) $this->get('key'); |
|
| 67 | + return (string)$this->get('key'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $this->addModelToCollection($i, $child); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - return $this->sets->values()->map(function (ViewableContract $child) { |
|
| 81 | + return $this->sets->values()->map(function(ViewableContract $child) { |
|
| 82 | 82 | return ($this->withSnippets && method_exists($child, 'withSnippets')) |
| 83 | 83 | ? $child->withSnippets()->setViewParent($this->parent)->renderView() |
| 84 | 84 | : $child->setViewParent($this->parent)->renderView(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | // Only published pages you fool! |
| 97 | 97 | // TODO: check for assistant instead of method existence |
| 98 | - if (method_exists($model, 'isPublished') && ! $model->isPublished()) { |
|
| 98 | + if (method_exists($model, 'isPublished') && !$model->isPublished()) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -87,11 +87,11 @@ |
||
| 87 | 87 | return parent::fields()->add( |
| 88 | 88 | $this->pageBuilderField(), |
| 89 | 89 | InputField::make('title')->translatable($this->model->availableLocales()) |
| 90 | - ->validation('required-fallback-locale|max:200', [], [ |
|
| 91 | - 'trans.'.config('app.fallback_locale', 'nl').'.title' => 'title', |
|
| 92 | - ]) |
|
| 93 | - ->label('De titel van je '.$this->model->labelSingular ?? 'pagina') |
|
| 94 | - ->description('Dit is de titel die zal worden getoond in de overzichten en modules.'), |
|
| 90 | + ->validation('required-fallback-locale|max:200', [], [ |
|
| 91 | + 'trans.'.config('app.fallback_locale', 'nl').'.title' => 'title', |
|
| 92 | + ]) |
|
| 93 | + ->label('De titel van je '.$this->model->labelSingular ?? 'pagina') |
|
| 94 | + ->description('Dit is de titel die zal worden getoond in de overzichten en modules.'), |
|
| 95 | 95 | InputField::make('seo_title') |
| 96 | 96 | ->translatable($this->model->availableLocales()) |
| 97 | 97 | ->label('Zoekmachine titel'), |
@@ -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; |
@@ -112,12 +112,12 @@ |
||
| 112 | 112 | $builder->where('locale', $locale); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if (! $includeRedirects) { |
|
| 115 | + if (!$includeRedirects) { |
|
| 116 | 116 | $builder->whereNull('redirect_id'); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if ($ignoredModel) { |
| 120 | - $builder->whereNotIn('id', function ($query) use ($ignoredModel) { |
|
| 120 | + $builder->whereNotIn('id', function($query) use ($ignoredModel) { |
|
| 121 | 121 | $query->select('id') |
| 122 | 122 | ->from('chief_urls') |
| 123 | 123 | ->where('model_type', '=', $ignoredModel->getMorphClass()) |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | public static function getByModel(Model $model) |
| 66 | 66 | { |
| 67 | 67 | return static::where('model_type', $model->getMorphClass()) |
| 68 | - ->where('model_id', $model->id) |
|
| 69 | - ->get(); |
|
| 68 | + ->where('model_id', $model->id) |
|
| 69 | + ->get(); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public static function findRecentRedirect(Model $model, string $locale): ?self |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | if ($ignoredModel) { |
| 135 | 135 | $builder->whereNotIn('id', function ($query) use ($ignoredModel) { |
| 136 | 136 | $query->select('id') |
| 137 | - ->from('chief_urls') |
|
| 138 | - ->where('model_type', '=', $ignoredModel->getMorphClass()) |
|
| 139 | - ->where('model_id', '=', $ignoredModel->id); |
|
| 137 | + ->from('chief_urls') |
|
| 138 | + ->where('model_type', '=', $ignoredModel->getMorphClass()) |
|
| 139 | + ->where('model_id', '=', $ignoredModel->id); |
|
| 140 | 140 | }); |
| 141 | 141 | } |
| 142 | 142 | |