@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | private function dropSeries() |
| 55 | 55 | { |
| 56 | - Schema::table('rainlab_blog_posts', function ($table) { |
|
| 57 | - $table->dropForeign([Series::TABLE_NAME . '_id']); |
|
| 56 | + Schema::table('rainlab_blog_posts', function($table) { |
|
| 57 | + $table->dropForeign([ Series::TABLE_NAME . '_id' ]); |
|
| 58 | 58 | $table->dropColumn(Series::TABLE_NAME . '_id'); |
| 59 | 59 | }); |
| 60 | 60 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if (!Schema::hasTable(Tag::TABLE_NAME)) { |
| 70 | 70 | Schema::create( |
| 71 | 71 | Tag::TABLE_NAME, |
| 72 | - static function ($table) { |
|
| 72 | + static function($table) { |
|
| 73 | 73 | $table->engine = 'InnoDB'; |
| 74 | 74 | |
| 75 | 75 | $table->increments('id'); |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | if (!Schema::hasTable(Tag::CROSS_REFERENCE_TABLE_NAME)) { |
| 84 | 84 | Schema::create( |
| 85 | 85 | Tag::CROSS_REFERENCE_TABLE_NAME, |
| 86 | - static function ($table) { |
|
| 86 | + static function($table) { |
|
| 87 | 87 | $table->engine = 'InnoDB'; |
| 88 | 88 | |
| 89 | 89 | $table->integer('tag_id')->unsigned()->nullable()->default(null); |
| 90 | 90 | $table->integer('post_id')->unsigned()->nullable()->default(null); |
| 91 | - $table->index(['tag_id', 'post_id']); |
|
| 91 | + $table->index([ 'tag_id', 'post_id' ]); |
|
| 92 | 92 | $table->foreign('tag_id', 'Tag reference')->references('id')->on(Tag::TABLE_NAME)->onDelete('cascade'); |
| 93 | 93 | $table->foreign('post_id', 'Post reference')->references('id')->on('rainlab_blog_posts')->onDelete('cascade'); |
| 94 | 94 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | if (!Schema::hasTable(Series::TABLE_NAME)) { |
| 105 | 105 | Schema::create( |
| 106 | 106 | Series::TABLE_NAME, |
| 107 | - static function ($table) { |
|
| 107 | + static function($table) { |
|
| 108 | 108 | $table->engine = 'InnoDB'; |
| 109 | 109 | |
| 110 | 110 | $table->increments('id'); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - Schema::table('rainlab_blog_posts', function ($table) { |
|
| 118 | + Schema::table('rainlab_blog_posts', function($table) { |
|
| 119 | 119 | $table->integer(Series::TABLE_NAME . '_id')->unsigned()->nullable()->default(null); |
| 120 | 120 | $table->foreign(Series::TABLE_NAME . '_id')->references('id')->on(Series::TABLE_NAME)->onDelete('cascade'); |
| 121 | 121 | }); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | const PLUGIN_NAME = 'PKleindienst.BlogSeries'; |
| 22 | 22 | |
| 23 | - private $migratedSeriesIds = []; |
|
| 23 | + private $migratedSeriesIds = [ ]; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Migrate plugin data |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | ) |
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | - $this->migratedSeriesIds[$blogTaxonomySeries->id] = $seriesRecord->id; |
|
| 93 | + $this->migratedSeriesIds[ $blogTaxonomySeries->id ] = $seriesRecord->id; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $this->command->info('All series have been migrated' . PHP_EOL); |
@@ -117,13 +117,13 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | $migratedSeries = array_flip($this->migratedSeriesIds); |
| 119 | 119 | |
| 120 | - DB::transaction(function () use ($relatedSeries, $migratedSeries) { |
|
| 120 | + DB::transaction(function() use ($relatedSeries, $migratedSeries) { |
|
| 121 | 121 | foreach ($relatedSeries as $relationRecord) { |
| 122 | - $seriesId = $migratedSeries[$relationRecord->series_id]; |
|
| 123 | - $relatedSeriesId = $migratedSeries[$relationRecord->related_id]; |
|
| 122 | + $seriesId = $migratedSeries[ $relationRecord->series_id ]; |
|
| 123 | + $relatedSeriesId = $migratedSeries[ $relationRecord->related_id ]; |
|
| 124 | 124 | |
| 125 | 125 | DB::table('ginopane_blogtaxonomy_related_series')->insert( |
| 126 | - ['series_id' => $seriesId, 'related_series_id' => $relatedSeriesId] |
|
| 126 | + [ 'series_id' => $seriesId, 'related_series_id' => $relatedSeriesId ] |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | $this->command->line( |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $migratedSeries = array_flip($this->migratedSeriesIds); |
| 160 | 160 | |
| 161 | - DB::transaction(function () use ($migratedSeries) { |
|
| 161 | + DB::transaction(function() use ($migratedSeries) { |
|
| 162 | 162 | foreach ($migratedSeries as $oldSeriesId => $newSeriesId) { |
| 163 | 163 | if (DB::table('rainlab_blog_posts') |
| 164 | 164 | ->where('series_id', $oldSeriesId) |
| 165 | - ->update(['ginopane_blogtaxonomy_series_id' => $newSeriesId]) |
|
| 165 | + ->update([ 'ginopane_blogtaxonomy_series_id' => $newSeriesId ]) |
|
| 166 | 166 | ) { |
| 167 | 167 | $this->command->line( |
| 168 | 168 | sprintf( |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | private static function separateParameters(array $parameters): array |
| 92 | 92 | { |
| 93 | 93 | $slugs = $parameters; |
| 94 | - $ids = []; |
|
| 94 | + $ids = [ ]; |
|
| 95 | 95 | |
| 96 | 96 | foreach ($slugs as $index => $potentialId) { |
| 97 | 97 | if (is_numeric($potentialId)) { |
| 98 | - $ids[] = $potentialId; |
|
| 99 | - unset($slugs[$index]); |
|
| 98 | + $ids[ ] = $potentialId; |
|
| 99 | + unset($slugs[ $index ]); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - return [$ids, $slugs]; |
|
| 103 | + return [ $ids, $slugs ]; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if (!empty($exceptCategories)) { |
| 113 | 113 | list($ids, $slugs) = self::separateParameters($exceptCategories); |
| 114 | 114 | |
| 115 | - $query->whereDoesntHave('categories', static function (Builder $innerQuery) use ($ids, $slugs) { |
|
| 115 | + $query->whereDoesntHave('categories', static function(Builder $innerQuery) use ($ids, $slugs) { |
|
| 116 | 116 | if (!empty($ids)) { |
| 117 | 117 | $innerQuery->whereIn('id', $ids); |
| 118 | 118 | } |
@@ -148,8 +148,8 @@ |
||
| 148 | 148 | { |
| 149 | 149 | $this->seriesPage = $this->getProperty('seriesPage'); |
| 150 | 150 | $this->orderBy = $this->getProperty('orderBy'); |
| 151 | - $this->displayEmpty = (bool) $this->getProperty('displayEmpty'); |
|
| 152 | - $this->fetchPosts = (bool) $this->getProperty('fetchPosts'); |
|
| 151 | + $this->displayEmpty = (bool)$this->getProperty('displayEmpty'); |
|
| 152 | + $this->fetchPosts = (bool)$this->getProperty('fetchPosts'); |
|
| 153 | 153 | $this->limit = $this->getProperty('limit'); |
| 154 | 154 | |
| 155 | 155 | // Exceptions |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @var Collection | array |
| 27 | 27 | */ |
| 28 | - public $tags = []; |
|
| 28 | + public $tags = [ ]; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Reference to the page name for linking to tag page |
@@ -270,16 +270,16 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | public function onRun() |
| 272 | 272 | { |
| 273 | - $this->tagPage = (string) $this->getProperty('tagPage'); |
|
| 274 | - $this->tagsPage = (string) $this->getProperty('tagsPage'); |
|
| 273 | + $this->tagPage = (string)$this->getProperty('tagPage'); |
|
| 274 | + $this->tagsPage = (string)$this->getProperty('tagsPage'); |
|
| 275 | 275 | |
| 276 | 276 | $this->orderBy = $this->getProperty('orderBy'); |
| 277 | 277 | $this->postSlug = $this->getProperty('postSlug'); |
| 278 | - $this->fetchPosts = (bool) $this->getProperty('fetchPosts'); |
|
| 279 | - $this->displayEmpty = (bool) $this->getProperty('displayEmpty'); |
|
| 280 | - $this->limit = (int) $this->getProperty('limit'); |
|
| 281 | - $this->exposeTotalCount = (bool) $this->getProperty('exposeTotalCount'); |
|
| 282 | - $this->enableTagFilter = (string) $this->getProperty('enableTagFilter'); |
|
| 278 | + $this->fetchPosts = (bool)$this->getProperty('fetchPosts'); |
|
| 279 | + $this->displayEmpty = (bool)$this->getProperty('displayEmpty'); |
|
| 280 | + $this->limit = (int)$this->getProperty('limit'); |
|
| 281 | + $this->exposeTotalCount = (bool)$this->getProperty('exposeTotalCount'); |
|
| 282 | + $this->enableTagFilter = (string)$this->getProperty('enableTagFilter'); |
|
| 283 | 283 | |
| 284 | 284 | // Exceptions |
| 285 | 285 | $this->populateExceptions(); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | $this->tagsPageUrl = $this->controller->pageUrl($this->tagsPage); |
| 320 | 320 | |
| 321 | - $this->setUrls($tags, $this->tagPage, $this->controller, ['tag' => $this->urlProperty($tagComponent, 'tag')]); |
|
| 321 | + $this->setUrls($tags, $this->tagPage, $this->controller, [ 'tag' => $this->urlProperty($tagComponent, 'tag') ]); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -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 | private function queryDisplayEmpty(Builder $query, array $options) |
| 105 | 105 | { |
| 106 | - if (empty($options['displayEmpty'])) { |
|
| 106 | + if (empty($options[ 'displayEmpty' ])) { |
|
| 107 | 107 | $query->having('posts_count', '>', 0); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function queryPostSlug(Builder $query, array $options) |
| 118 | 118 | { |
| 119 | - if (!empty($options['post'])) { |
|
| 119 | + if (!empty($options[ 'post' ])) { |
|
| 120 | 120 | $query->whereHas( |
| 121 | 121 | 'posts', |
| 122 | - static function ($query) use ($options) { |
|
| 123 | - ModelAbstract::whereTranslatableProperty($query, 'slug', $options['post']); |
|
| 122 | + static function($query) use ($options) { |
|
| 123 | + ModelAbstract::whereTranslatableProperty($query, 'slug', $options[ 'post' ]); |
|
| 124 | 124 | } |
| 125 | 125 | ); |
| 126 | 126 | } |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function queryLimit(Builder $query, array $options) |
| 136 | 136 | { |
| 137 | - if (!empty($options['limit'])) { |
|
| 138 | - $query->take($options['limit']); |
|
| 137 | + if (!empty($options[ 'limit' ])) { |
|
| 138 | + $query->take($options[ 'limit' ]); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | private function queryOrderBy(Builder $query, array $options) |
| 149 | 149 | { |
| 150 | - if (!empty($options['sort']) && \array_key_exists($options['sort'], static::$sortingOptions)) { |
|
| 151 | - if ($options['sort'] === 'random') { |
|
| 150 | + if (!empty($options[ 'sort' ]) && \array_key_exists($options[ 'sort' ], static::$sortingOptions)) { |
|
| 151 | + if ($options[ 'sort' ] === 'random') { |
|
| 152 | 152 | $query->inRandomOrder(); |
| 153 | 153 | } else { |
| 154 | - list($sortField, $sortDirection) = explode(' ', $options['sort']); |
|
| 154 | + list($sortField, $sortDirection) = explode(' ', $options[ 'sort' ]); |
|
| 155 | 155 | |
| 156 | 156 | $query->orderBy($sortField, $sortDirection); |
| 157 | 157 | } |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | private function withRelation(Builder $query, array $options) |
| 168 | 168 | { |
| 169 | - if (!empty($options['fetchPosts'])) { |
|
| 169 | + if (!empty($options[ 'fetchPosts' ])) { |
|
| 170 | 170 | $query->with( |
| 171 | 171 | [ |
| 172 | - 'posts' => function (HasMany $query) use ($options) { |
|
| 172 | + 'posts' => function(HasMany $query) use ($options) { |
|
| 173 | 173 | $query->isPublished(); |
| 174 | 174 | |
| 175 | 175 | $this->handleExceptions($query->getQuery(), $options); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $query->withCount( |
| 182 | 182 | [ |
| 183 | - 'posts' => function ($query) use ($options) { |
|
| 183 | + 'posts' => function($query) use ($options) { |
|
| 184 | 184 | $query->isPublished(); |
| 185 | 185 | |
| 186 | 186 | $this->handleExceptions($query, $options); |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | private function handleExceptions(Builder $query, array $options) |
| 205 | 205 | { |
| 206 | - if (!empty($options['exceptPosts'])) { |
|
| 207 | - PostListExceptionsTrait::handleExceptionsByPost($query, $options['exceptPosts']); |
|
| 206 | + if (!empty($options[ 'exceptPosts' ])) { |
|
| 207 | + PostListExceptionsTrait::handleExceptionsByPost($query, $options[ 'exceptPosts' ]); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if (!empty($options['exceptCategories'])) { |
|
| 211 | - PostListExceptionsTrait::handleExceptionsByCategory($query, $options['exceptCategories']); |
|
| 210 | + if (!empty($options[ 'exceptCategories' ])) { |
|
| 211 | + PostListExceptionsTrait::handleExceptionsByCategory($query, $options[ 'exceptCategories' ]); |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @var Collection | array |
| 26 | 26 | */ |
| 27 | - public $posts = []; |
|
| 27 | + public $posts = [ ]; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Parameter to use for the page number |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $this->pageParam = $this->paramName('page'); |
| 244 | 244 | $this->currentPage = (int)$this->property('page', 1) ?: (int)post('page'); |
| 245 | 245 | $this->resultsPerPage = (int)$this->property('resultsPerPage') |
| 246 | - ?: $this->defineProperties()['resultsPerPage']['default']; |
|
| 246 | + ?: $this->defineProperties()[ 'resultsPerPage' ][ 'default' ]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -50,12 +50,12 @@ |
||
| 50 | 50 | if (!Schema::hasTable(Series::RELATED_SERIES_TABLE_NAME)) { |
| 51 | 51 | Schema::create( |
| 52 | 52 | Series::RELATED_SERIES_TABLE_NAME, |
| 53 | - static function ($table) { |
|
| 53 | + static function($table) { |
|
| 54 | 54 | $table->engine = 'InnoDB'; |
| 55 | 55 | |
| 56 | 56 | $table->integer('series_id')->unsigned(); |
| 57 | 57 | $table->integer('related_series_id')->unsigned(); |
| 58 | - $table->index(['series_id', 'related_series_id'], 'related_series_index'); |
|
| 58 | + $table->index([ 'series_id', 'related_series_id' ], 'related_series_index'); |
|
| 59 | 59 | |
| 60 | 60 | $table |
| 61 | 61 | ->foreign('series_id', 'Series reference') |