@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * @var array |
| 22 | 22 | */ |
| 23 | - public static $sortingOptions = []; |
|
| 23 | + public static $sortingOptions = [ ]; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Sets the URL attribute with a URL to this object |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return mixed |
| 55 | 55 | */ |
| 56 | - public function scopeListFrontend(Builder $query, array $options = []) |
|
| 56 | + public function scopeListFrontend(Builder $query, array $options = [ ]) |
|
| 57 | 57 | { |
| 58 | 58 | $this->withRelation($query, $options); |
| 59 | 59 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function queryDisplayEmpty(Builder $query, array $options) |
| 105 | 105 | { |
| 106 | - if (empty($options['displayEmpty'])) { |
|
| 106 | + if (empty($options[ 'displayEmpty' ])) { |
|
| 107 | 107 | $query |
| 108 | 108 | ->having('posts_count', '>', 0); |
| 109 | 109 | } |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function queryPostSlug(Builder $query, array $options) |
| 119 | 119 | { |
| 120 | - if (!empty($options['post'])) { |
|
| 120 | + if (!empty($options[ 'post' ])) { |
|
| 121 | 121 | $query->whereHas( |
| 122 | 122 | 'posts', |
| 123 | - static function ($query) use ($options) { |
|
| 124 | - ModelAbstract::whereTranslatableProperty($query, 'slug', $options['post']); |
|
| 123 | + static function($query) use ($options) { |
|
| 124 | + ModelAbstract::whereTranslatableProperty($query, 'slug', $options[ 'post' ]); |
|
| 125 | 125 | } |
| 126 | 126 | ); |
| 127 | 127 | } |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | private function queryLimit(Builder $query, array $options) |
| 137 | 137 | { |
| 138 | - if (!empty($options['limit'])) { |
|
| 139 | - $query->take($options['limit']); |
|
| 138 | + if (!empty($options[ 'limit' ])) { |
|
| 139 | + $query->take($options[ 'limit' ]); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | private function queryOrderBy(Builder $query, array $options) |
| 150 | 150 | { |
| 151 | - if (!empty($options['sort']) && \array_key_exists($options['sort'], static::$sortingOptions)) { |
|
| 152 | - if ($options['sort'] === 'random') { |
|
| 151 | + if (!empty($options[ 'sort' ]) && \array_key_exists($options[ 'sort' ], static::$sortingOptions)) { |
|
| 152 | + if ($options[ 'sort' ] === 'random') { |
|
| 153 | 153 | $query->inRandomOrder(); |
| 154 | 154 | } else { |
| 155 | - list($sortField, $sortDirection) = explode(' ', $options['sort']); |
|
| 155 | + list($sortField, $sortDirection) = explode(' ', $options[ 'sort' ]); |
|
| 156 | 156 | |
| 157 | 157 | $query->orderBy($sortField, $sortDirection); |
| 158 | 158 | } |
@@ -167,10 +167,10 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | protected function withRelation(Builder $query, array $options) |
| 169 | 169 | { |
| 170 | - if (!empty($options['fetchPosts'])) { |
|
| 170 | + if (!empty($options[ 'fetchPosts' ])) { |
|
| 171 | 171 | $query->with( |
| 172 | 172 | [ |
| 173 | - 'posts' => static function (HasMany $query) use ($options) { |
|
| 173 | + 'posts' => static function(HasMany $query) use ($options) { |
|
| 174 | 174 | $query->isPublished(); |
| 175 | 175 | |
| 176 | 176 | self::handleExceptions($query->getQuery(), $options); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | $query->withCount( |
| 183 | 183 | [ |
| 184 | - 'posts' => static function ($query) use ($options) { |
|
| 184 | + 'posts' => static function($query) use ($options) { |
|
| 185 | 185 | $query->isPublished(); |
| 186 | 186 | |
| 187 | 187 | self::handleExceptions($query, $options); |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | protected static function handleExceptions(Builder $query, array $options) |
| 206 | 206 | { |
| 207 | - if (!empty($options['includeCategories'])) { |
|
| 208 | - PostListFiltersTrait::handleInclusionsByCategory($query, $options['includeCategories']); |
|
| 207 | + if (!empty($options[ 'includeCategories' ])) { |
|
| 208 | + PostListFiltersTrait::handleInclusionsByCategory($query, $options[ 'includeCategories' ]); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if (!empty($options['exceptPosts'])) { |
|
| 212 | - PostListFiltersTrait::handleExceptionsByPost($query, $options['exceptPosts']); |
|
| 211 | + if (!empty($options[ 'exceptPosts' ])) { |
|
| 212 | + PostListFiltersTrait::handleExceptionsByPost($query, $options[ 'exceptPosts' ]); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if (!empty($options['exceptCategories'])) { |
|
| 216 | - PostListFiltersTrait::handleExceptionsByCategory($query, $options['exceptCategories']); |
|
| 215 | + if (!empty($options[ 'exceptCategories' ])) { |
|
| 216 | + PostListFiltersTrait::handleExceptionsByCategory($query, $options[ 'exceptCategories' ]); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -108,16 +108,16 @@ discard block |
||
| 108 | 108 | private static function separateParameters(array $parameters): array |
| 109 | 109 | { |
| 110 | 110 | $slugs = $parameters; |
| 111 | - $ids = []; |
|
| 111 | + $ids = [ ]; |
|
| 112 | 112 | |
| 113 | 113 | foreach ($slugs as $index => $potentialId) { |
| 114 | 114 | if (is_numeric($potentialId)) { |
| 115 | - $ids[] = $potentialId; |
|
| 116 | - unset($slugs[$index]); |
|
| 115 | + $ids[ ] = $potentialId; |
|
| 116 | + unset($slugs[ $index ]); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - return [$ids, $slugs]; |
|
| 120 | + return [ $ids, $slugs ]; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | if (!empty($exceptCategories)) { |
| 130 | 130 | list($ids, $slugs) = self::separateParameters($exceptCategories); |
| 131 | 131 | |
| 132 | - $query->whereDoesntHave('categories', static function (Builder $innerQuery) use ($ids, $slugs) { |
|
| 132 | + $query->whereDoesntHave('categories', static function(Builder $innerQuery) use ($ids, $slugs) { |
|
| 133 | 133 | if (!empty($ids)) { |
| 134 | 134 | $innerQuery->whereIn('id', $ids); |
| 135 | 135 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | if (!empty($includeCategories)) { |
| 151 | 151 | list($ids, $slugs) = self::separateParameters($includeCategories); |
| 152 | 152 | |
| 153 | - $query->whereHas('categories', static function (Builder $innerQuery) use ($ids, $slugs) { |
|
| 153 | + $query->whereHas('categories', static function(Builder $innerQuery) use ($ids, $slugs) { |
|
| 154 | 154 | if (!empty($ids)) { |
| 155 | 155 | $innerQuery->whereIn('id', $ids); |
| 156 | 156 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function up() |
| 20 | 20 | { |
| 21 | 21 | if (Schema::hasTable(Series::TABLE_NAME)) { |
| 22 | - Schema::table(Series::TABLE_NAME, static function ($table) { |
|
| 22 | + Schema::table(Series::TABLE_NAME, static function($table) { |
|
| 23 | 23 | $table->string('status')->default(Series::STATUS_ACTIVE); |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function down() |
| 32 | 32 | { |
| 33 | 33 | if (Schema::hasTable(Series::TABLE_NAME)) { |
| 34 | - Schema::table(Series::TABLE_NAME, static function ($table) { |
|
| 34 | + Schema::table(Series::TABLE_NAME, static function($table) { |
|
| 35 | 35 | $table->dropColumn('status'); |
| 36 | 36 | }); |
| 37 | 37 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $series = SeriesModel::whereId($recordId)->first(); |
| 58 | 58 | |
| 59 | 59 | if ($series !== null) { |
| 60 | - $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.edit_title', ['series' => $series->title]); |
|
| 60 | + $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.edit_title', [ 'series' => $series->title ]); |
|
| 61 | 61 | } else { |
| 62 | 62 | $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.series_does_not_exist'); |
| 63 | 63 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function onBulkDelete() |
| 74 | 74 | { |
| 75 | - if ($checkedIds = (array)post('checked', [])) { |
|
| 75 | + if ($checkedIds = (array)post('checked', [ ])) { |
|
| 76 | 76 | $delete = SeriesModel::whereIn('id', $checkedIds)->delete(); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | // Add a "url" helper attribute for linking to each post and category |
| 62 | 62 | if (!empty($this->postPage) && $posts && $posts->count()) { |
| 63 | - $posts->each(function ($post) { |
|
| 63 | + $posts->each(function($post) { |
|
| 64 | 64 | $this->setPostUrl($post); |
| 65 | 65 | |
| 66 | 66 | if (!empty($this->categoryPage) && $post->categories->count()) { |
| 67 | - $post->categories->each(function ($category) { |
|
| 67 | + $post->categories->each(function($category) { |
|
| 68 | 68 | /** @var Category $category */ |
| 69 | 69 | $category->setUrl( |
| 70 | 70 | $this->categoryPage, |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | if ($component !== null && ($property = $component->property($name))) { |
| 102 | 102 | preg_match('/{{ :([^ ]+) }}/', $property, $matches); |
| 103 | 103 | |
| 104 | - if (isset($matches[1])) { |
|
| 105 | - $property = $matches[1]; |
|
| 104 | + if (isset($matches[ 1 ])) { |
|
| 105 | + $property = $matches[ 1 ]; |
|
| 106 | 106 | } |
| 107 | 107 | } else { |
| 108 | 108 | $property = $name; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function getProperty(string $property, $default = null) |
| 124 | 124 | { |
| 125 | - return $this->property($property, $this->defineProperties()[$property]['default'] ?? $default); |
|
| 125 | + return $this->property($property, $this->defineProperties()[ $property ][ 'default' ] ?? $default); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @var Collection | array |
| 31 | 31 | */ |
| 32 | - public $posts = []; |
|
| 32 | + public $posts = [ ]; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Reference to the page name for linking to posts |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | private function prepareVars() |
| 134 | 134 | { |
| 135 | - $this->orderBy = $this->page['orderBy'] = $this->property('orderBy'); |
|
| 135 | + $this->orderBy = $this->page[ 'orderBy' ] = $this->property('orderBy'); |
|
| 136 | 136 | |
| 137 | 137 | // Page links |
| 138 | - $this->postPage = $this->page['postPage' ] = $this->property('postPage'); |
|
| 138 | + $this->postPage = $this->page[ 'postPage' ] = $this->property('postPage'); |
|
| 139 | 139 | |
| 140 | 140 | // Exceptions |
| 141 | 141 | $this->populateFilters(); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | $query = Post::isPublished() |
| 178 | 178 | ->where('id', '<>', $post->id) |
| 179 | - ->whereHas('tags', function ($tag) use ($tagIds) { |
|
| 179 | + ->whereHas('tags', function($tag) use ($tagIds) { |
|
| 180 | 180 | $tag->whereIn('id', $tagIds); |
| 181 | 181 | }) |
| 182 | 182 | ->with('tags'); |
@@ -88,14 +88,14 @@ |
||
| 88 | 88 | */ |
| 89 | 89 | protected function getPostsQuery() |
| 90 | 90 | { |
| 91 | - $query = Post::whereHas('series', function ($query) { |
|
| 91 | + $query = Post::whereHas('series', function($query) { |
|
| 92 | 92 | $query->whereTranslatable('slug', $this->series->slug); |
| 93 | 93 | }); |
| 94 | 94 | |
| 95 | 95 | $tagIds = $this->series->tags->lists('id'); |
| 96 | 96 | |
| 97 | 97 | if (!empty($tagIds) && $this->includeTaggedPosts) { |
| 98 | - $query->orWhereHas('tags', function ($tag) use ($tagIds) { |
|
| 98 | + $query->orWhereHas('tags', function($tag) use ($tagIds) { |
|
| 99 | 99 | $tag->whereIn('id', $tagIds); |
| 100 | 100 | }); |
| 101 | 101 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | public function registerNavigation(): void |
| 134 | 134 | { |
| 135 | 135 | // Extend the navigation |
| 136 | - Event::listen('backend.menu.extendItems', function ($manager) { |
|
| 136 | + Event::listen('backend.menu.extendItems', function($manager) { |
|
| 137 | 137 | $manager->addSideMenuItems(self::REQUIRED_PLUGIN_RAINLAB_BLOG, 'blog', [ |
| 138 | 138 | 'series' => [ |
| 139 | 139 | 'label' => self::LOCALIZATION_KEY . 'navigation.sidebar.series', |
@@ -194,47 +194,47 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | private function extendPostModel(): void |
| 196 | 196 | { |
| 197 | - PostModel::extend(function ($model) { |
|
| 197 | + PostModel::extend(function($model) { |
|
| 198 | 198 | $model->morphToMany = [ |
| 199 | - 'tags' => [Tag::class, 'name' => Tag::PIVOT_COLUMN] |
|
| 199 | + 'tags' => [ Tag::class, 'name' => Tag::PIVOT_COLUMN ] |
|
| 200 | 200 | ]; |
| 201 | 201 | |
| 202 | - $model->belongsTo['series'] = [ |
|
| 202 | + $model->belongsTo[ 'series' ] = [ |
|
| 203 | 203 | Series::class, |
| 204 | 204 | 'key' => Series::TABLE_NAME . "_id" |
| 205 | 205 | ]; |
| 206 | 206 | |
| 207 | 207 | if ($this->getSettings()->postTypesEnabled()) { |
| 208 | - $model->belongsTo['post_type'] = [ |
|
| 208 | + $model->belongsTo[ 'post_type' ] = [ |
|
| 209 | 209 | PostType::class, |
| 210 | 210 | 'key' => PostType::TABLE_NAME . "_id" |
| 211 | 211 | ]; |
| 212 | 212 | |
| 213 | - $model->addJsonable(PostType::TABLE_NAME. '_attributes'); |
|
| 213 | + $model->addJsonable(PostType::TABLE_NAME . '_attributes'); |
|
| 214 | 214 | |
| 215 | 215 | $model->addDynamicMethod('typeAttributes', function() use ($model) { |
| 216 | 216 | if (!empty($model->post_type->id)) { |
| 217 | - $rawFields = $model->{PostType::TABLE_NAME. '_attributes'}[0] ?? []; |
|
| 218 | - $prefix = $model->post_type->id.'.'; |
|
| 219 | - $fields = []; |
|
| 217 | + $rawFields = $model->{PostType::TABLE_NAME . '_attributes'}[ 0 ] ?? [ ]; |
|
| 218 | + $prefix = $model->post_type->id . '.'; |
|
| 219 | + $fields = [ ]; |
|
| 220 | 220 | |
| 221 | 221 | foreach ($rawFields as $code => $value) { |
| 222 | 222 | if (strpos($code, $prefix) === 0) { |
| 223 | - $fields[str_replace($prefix, '', $code)] = $value; |
|
| 223 | + $fields[ str_replace($prefix, '', $code) ] = $value; |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $fields; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - return []; |
|
| 230 | + return [ ]; |
|
| 231 | 231 | }); |
| 232 | 232 | |
| 233 | 233 | $model->addDynamicMethod('typeAttribute', function(string $code) use ($model) { |
| 234 | 234 | if (!empty($model->post_type->id)) { |
| 235 | 235 | $attributeKey = sprintf('%s.%s', $model->post_type->id, $code); |
| 236 | 236 | |
| 237 | - return $model->{PostType::TABLE_NAME. '_attributes'}[0][$attributeKey] ?? null; |
|
| 237 | + return $model->{PostType::TABLE_NAME . '_attributes'}[ 0 ][ $attributeKey ] ?? null; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | return $model->post_type->id; |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | private function extendPostsController(): void |
| 262 | 262 | { |
| 263 | - PostsController::extendFormFields(function (Form $form, $model) { |
|
| 263 | + PostsController::extendFormFields(function(Form $form, $model) { |
|
| 264 | 264 | if (!$model instanceof PostModel) { |
| 265 | 265 | return; |
| 266 | 266 | } |
@@ -311,8 +311,8 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | private function extendCategoriesController(): void |
| 313 | 313 | { |
| 314 | - CategoriesController::extend(function (Controller $controller) { |
|
| 315 | - $controller->implement[] = RelationController::class; |
|
| 314 | + CategoriesController::extend(function(Controller $controller) { |
|
| 315 | + $controller->implement[ ] = RelationController::class; |
|
| 316 | 316 | $relationConfig = '$/' . self::DIRECTORY_KEY . '/controllers/category/config_relation.yaml'; |
| 317 | 317 | |
| 318 | 318 | if (property_exists($controller, 'relationConfig')) { |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | private function extendCategoriesModel(): void |
| 341 | 341 | { |
| 342 | - CategoryModel::extend(function ($model) { |
|
| 342 | + CategoryModel::extend(function($model) { |
|
| 343 | 343 | if ($this->getSettings()->postCategoriesCoverImageEnabled()) { |
| 344 | - $model->attachOne['cover_image'] = [ |
|
| 344 | + $model->attachOne[ 'cover_image' ] = [ |
|
| 345 | 345 | File::class, 'delete' => true |
| 346 | 346 | ]; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | if ($this->getSettings()->postCategoriesFeaturedImagesEnabled()) { |
| 350 | - $model->attachMany['featured_images'] = [ |
|
| 350 | + $model->attachMany[ 'featured_images' ] = [ |
|
| 351 | 351 | File::class, 'order' => 'sort_order', 'delete' => true |
| 352 | 352 | ]; |
| 353 | 353 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | private function extendCategoriesFormFields(): void |
| 358 | 358 | { |
| 359 | - CategoriesController::extendFormFields(function ($form, $model) { |
|
| 359 | + CategoriesController::extendFormFields(function($form, $model) { |
|
| 360 | 360 | if (!$model instanceof CategoryModel) { |
| 361 | 361 | return; |
| 362 | 362 | } |
@@ -401,15 +401,15 @@ discard block |
||
| 401 | 401 | private function extendValidator(): void |
| 402 | 402 | { |
| 403 | 403 | if ($this->getSettings()->postTypesEnabled()) { |
| 404 | - Validator::extend('unique_in_repeater', function ($attribute, $value, $parameters, $validator) { |
|
| 404 | + Validator::extend('unique_in_repeater', function($attribute, $value, $parameters, $validator) { |
|
| 405 | 405 | $attributeNameParts = explode('.', $attribute); |
| 406 | 406 | |
| 407 | 407 | $repeaterName = reset($attributeNameParts); |
| 408 | 408 | $fieldName = end($attributeNameParts); |
| 409 | 409 | |
| 410 | - $repeaterData = isset($validator->getData()[$repeaterName]) |
|
| 411 | - ? (array) $validator->getData()[$repeaterName] |
|
| 412 | - : []; |
|
| 410 | + $repeaterData = isset($validator->getData()[ $repeaterName ]) |
|
| 411 | + ? (array)$validator->getData()[ $repeaterName ] |
|
| 412 | + : [ ]; |
|
| 413 | 413 | |
| 414 | 414 | $fieldData = array_column($repeaterData, $fieldName); |
| 415 | 415 | |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | private function transformPostCategoriesIntoTaglist(Form $form, string $tab) |
| 426 | 426 | { |
| 427 | 427 | $categoriesConfig = $form->getField('categories')->config; |
| 428 | - $categoriesConfig['tab'] = $tab; |
|
| 429 | - $categoriesConfig['mode'] = 'relation'; |
|
| 430 | - $categoriesConfig['type'] = 'taglist'; |
|
| 431 | - $categoriesConfig['label'] = 'rainlab.blog::lang.post.tab_categories'; |
|
| 432 | - $categoriesConfig['comment'] = "rainlab.blog::lang.post.categories_comment"; |
|
| 433 | - $categoriesConfig['placeholder'] = self::LOCALIZATION_KEY . 'placeholders.categories'; |
|
| 434 | - unset($categoriesConfig['commentAbove']); |
|
| 428 | + $categoriesConfig[ 'tab' ] = $tab; |
|
| 429 | + $categoriesConfig[ 'mode' ] = 'relation'; |
|
| 430 | + $categoriesConfig[ 'type' ] = 'taglist'; |
|
| 431 | + $categoriesConfig[ 'label' ] = 'rainlab.blog::lang.post.tab_categories'; |
|
| 432 | + $categoriesConfig[ 'comment' ] = "rainlab.blog::lang.post.categories_comment"; |
|
| 433 | + $categoriesConfig[ 'placeholder' ] = self::LOCALIZATION_KEY . 'placeholders.categories'; |
|
| 434 | + unset($categoriesConfig[ 'commentAbove' ]); |
|
| 435 | 435 | |
| 436 | 436 | $form->removeField('categories'); |
| 437 | 437 | return $categoriesConfig; |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | $condition = implode( |
| 456 | 456 | array_map( |
| 457 | - static function ($value) { |
|
| 457 | + static function($value) { |
|
| 458 | 458 | return "[$value]"; |
| 459 | 459 | }, |
| 460 | 460 | PostType::all()->pluck('id')->toArray() |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | 'style' => 'accordion', |
| 481 | 481 | 'tab' => $tab, |
| 482 | 482 | 'form' => [ |
| 483 | - 'fields' => [] |
|
| 483 | + 'fields' => [ ] |
|
| 484 | 484 | ] |
| 485 | 485 | ]; |
| 486 | 486 | |
@@ -490,51 +490,51 @@ discard block |
||
| 490 | 490 | (!empty($model->id) && !empty($model->post_type->id) && $postType = $model->post_type) |
| 491 | 491 | ) { |
| 492 | 492 | if (!empty($postType->type_attributes)) { |
| 493 | - $fields = []; |
|
| 493 | + $fields = [ ]; |
|
| 494 | 494 | |
| 495 | 495 | foreach ($postType->type_attributes as $typeAttribute) { |
| 496 | - if (empty($typeAttribute['code'])) { |
|
| 496 | + if (empty($typeAttribute[ 'code' ])) { |
|
| 497 | 497 | continue; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - $field = []; |
|
| 500 | + $field = [ ]; |
|
| 501 | 501 | |
| 502 | - $type = $typeAttribute['type'] ?? 'text'; |
|
| 502 | + $type = $typeAttribute[ 'type' ] ?? 'text'; |
|
| 503 | 503 | |
| 504 | 504 | switch ($type) { |
| 505 | 505 | case 'file': |
| 506 | 506 | case 'image': |
| 507 | - $field['type'] = 'mediafinder'; |
|
| 508 | - $field['mode'] = $type; |
|
| 509 | - $field['imageWidth'] = 200; |
|
| 507 | + $field[ 'type' ] = 'mediafinder'; |
|
| 508 | + $field[ 'mode' ] = $type; |
|
| 509 | + $field[ 'imageWidth' ] = 200; |
|
| 510 | 510 | break; |
| 511 | 511 | case 'dropdown': |
| 512 | - $field['type'] = $type; |
|
| 512 | + $field[ 'type' ] = $type; |
|
| 513 | 513 | |
| 514 | - $options = array_map(static function ($value) { |
|
| 514 | + $options = array_map(static function($value) { |
|
| 515 | 515 | return trim($value); |
| 516 | - }, explode(',', $typeAttribute['dropdown_options'] ?? '')); |
|
| 516 | + }, explode(',', $typeAttribute[ 'dropdown_options' ] ?? '')); |
|
| 517 | 517 | |
| 518 | - $field['options'] = $options; |
|
| 518 | + $field[ 'options' ] = $options; |
|
| 519 | 519 | |
| 520 | 520 | break; |
| 521 | 521 | case 'text': |
| 522 | 522 | case 'textarea': |
| 523 | - $field['type'] = $type; |
|
| 523 | + $field[ 'type' ] = $type; |
|
| 524 | 524 | break; |
| 525 | 525 | case 'datepicker': |
| 526 | - $field['type'] = $type; |
|
| 527 | - $field['mode'] = $typeAttribute['datepicker_mode'] ?? 'date'; |
|
| 526 | + $field[ 'type' ] = $type; |
|
| 527 | + $field[ 'mode' ] = $typeAttribute[ 'datepicker_mode' ] ?? 'date'; |
|
| 528 | 528 | |
| 529 | 529 | break; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - $field['label'] = $typeAttribute['name'] ?? ''; |
|
| 532 | + $field[ 'label' ] = $typeAttribute[ 'name' ] ?? ''; |
|
| 533 | 533 | |
| 534 | - $fields[sprintf("%s.%s", $postType->id, $typeAttribute['code'])] = $field; |
|
| 534 | + $fields[ sprintf("%s.%s", $postType->id, $typeAttribute[ 'code' ]) ] = $field; |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - $typeAttributes['form']['fields'] = $fields; |
|
| 537 | + $typeAttributes[ 'form' ][ 'fields' ] = $fields; |
|
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | private function extendPostListColumns(): void |
| 547 | 547 | { |
| 548 | - Event::listen('backend.list.extendColumns', function (Lists $listWidget) { |
|
| 548 | + Event::listen('backend.list.extendColumns', function(Lists $listWidget) { |
|
| 549 | 549 | // Only for the Posts controller |
| 550 | 550 | if (!$listWidget->getController() instanceof PostsController) { |
| 551 | 551 | return; |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | private function extendPostFilterScopes(): void |
| 574 | 574 | { |
| 575 | - Event::listen('backend.filter.extendScopes', function (Filter $filterWidget) { |
|
| 575 | + Event::listen('backend.filter.extendScopes', function(Filter $filterWidget) { |
|
| 576 | 576 | if ($this->getSettings()->postTypesEnabled()) { |
| 577 | 577 | $filterWidget->addScopes([ |
| 578 | 578 | 'type' => [ |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $postType = PostType::whereId($recordId)->first(); |
| 58 | 58 | |
| 59 | 59 | if ($postType !== null) { |
| 60 | - $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.post_types.edit_title', ['post_type' => $postType->name]); |
|
| 60 | + $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.post_types.edit_title', [ 'post_type' => $postType->name ]); |
|
| 61 | 61 | } else { |
| 62 | 62 | $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.post_types.post_type_does_not_exist'); |
| 63 | 63 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function onBulkDelete() |
| 74 | 74 | { |
| 75 | - if ($checkedIds = (array)post('checked', [])) { |
|
| 75 | + if ($checkedIds = (array)post('checked', [ ])) { |
|
| 76 | 76 | $delete = PostType::whereIn('id', $checkedIds)->delete(); |
| 77 | 77 | } |
| 78 | 78 | |