| @@ -46,7 +46,7 @@ discard block | ||
| 46 | 46 | * | 
| 47 | 47 | * @var array | 
| 48 | 48 | */ | 
| 49 | - public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel']; | |
| 49 | + public $implement = [ '@RainLab.Translate.Behaviors.TranslatableModel' ]; | |
| 50 | 50 | |
| 51 | 51 | /** | 
| 52 | 52 | * Translatable properties, indexed property will be available in queries | 
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | /** | 
| 65 | 65 | * @var array | 
| 66 | 66 | */ | 
| 67 | - protected $slugs = ['slug' => 'name']; | |
| 67 | + protected $slugs = [ 'slug' => 'name' ]; | |
| 68 | 68 | |
| 69 | 69 | /** | 
| 70 | 70 | * Relations | 
| @@ -72,8 +72,8 @@ discard block | ||
| 72 | 72 | * @var array | 
| 73 | 73 | */ | 
| 74 | 74 | public $morphedByMany = [ | 
| 75 | - 'posts' => [Post::class, 'name' => Tag::PIVOT_COLUMN], | |
| 76 | - 'series' => [Series::class, 'name' => Tag::PIVOT_COLUMN], | |
| 75 | + 'posts' => [ Post::class, 'name' => Tag::PIVOT_COLUMN ], | |
| 76 | + 'series' => [ Series::class, 'name' => Tag::PIVOT_COLUMN ], | |
| 77 | 77 | ]; | 
| 78 | 78 | |
| 79 | 79 | /** | 
| @@ -182,12 +182,12 @@ discard block | ||
| 182 | 182 |      { | 
| 183 | 183 | parent::queryPostSlug($query, $options); | 
| 184 | 184 | |
| 185 | -        if (!empty($options['post']) && !empty($options['includeSeriesTags'])) { | |
| 186 | -            $query->orWhereHas('series', static function ($query) use ($options) { | |
| 185 | +        if (!empty($options[ 'post' ]) && !empty($options[ 'includeSeriesTags' ])) { | |
| 186 | +            $query->orWhereHas('series', static function($query) use ($options) { | |
| 187 | 187 | $query->whereHas( | 
| 188 | 188 | 'posts', | 
| 189 | -                    static function ($query) use ($options) { | |
| 190 | - ModelAbstract::whereTranslatableProperty($query, 'slug', $options['post']); | |
| 189 | +                    static function($query) use ($options) { | |
| 190 | + ModelAbstract::whereTranslatableProperty($query, 'slug', $options[ 'post' ]); | |
| 191 | 191 | }); | 
| 192 | 192 | }); | 
| 193 | 193 | } | 
| @@ -201,10 +201,10 @@ discard block | ||
| 201 | 201 | */ | 
| 202 | 202 | private function postRelation(Builder $query, array $options) | 
| 203 | 203 |      { | 
| 204 | -        if (!empty($options['fetchPosts'])) { | |
| 204 | +        if (!empty($options[ 'fetchPosts' ])) { | |
| 205 | 205 | $query->with( | 
| 206 | 206 | [ | 
| 207 | -                    'posts' => static function (MorphToMany $query) use ($options) { | |
| 207 | +                    'posts' => static function(MorphToMany $query) use ($options) { | |
| 208 | 208 | $query->isPublished(); | 
| 209 | 209 | |
| 210 | 210 | self::handleExceptions($query->getQuery(), $options); | 
| @@ -215,7 +215,7 @@ discard block | ||
| 215 | 215 | |
| 216 | 216 | $query->withCount( | 
| 217 | 217 | [ | 
| 218 | -                'posts' => static function ($query) use ($options) { | |
| 218 | +                'posts' => static function($query) use ($options) { | |
| 219 | 219 | $query->isPublished(); | 
| 220 | 220 | |
| 221 | 221 | self::handleExceptions($query, $options); | 
| @@ -234,13 +234,13 @@ discard block | ||
| 234 | 234 |      { | 
| 235 | 235 |          $query->withCount('series'); | 
| 236 | 236 | |
| 237 | -        if (!empty($options['fetchSeriesPostCount'])) { | |
| 237 | +        if (!empty($options[ 'fetchSeriesPostCount' ])) { | |
| 238 | 238 | $query->with( | 
| 239 | 239 | [ | 
| 240 | -                    'series' => static function (MorphToMany $query) use ($options) { | |
| 240 | +                    'series' => static function(MorphToMany $query) use ($options) { | |
| 241 | 241 | $query->withCount( | 
| 242 | 242 | [ | 
| 243 | -                                'posts' => static function ($query) use ($options) { | |
| 243 | +                                'posts' => static function($query) use ($options) { | |
| 244 | 244 | $query->isPublished(); | 
| 245 | 245 | |
| 246 | 246 | self::handleExceptions($query, $options); | 
| @@ -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 | 
| 108 | 108 |                  ->having('posts_count', '>', 0) | 
| 109 | 109 |                  ->orHaving('series_count', '>', 0); | 
| @@ -118,11 +118,11 @@ discard block | ||
| 118 | 118 | */ | 
| 119 | 119 | protected function queryPostSlug(Builder $query, array $options) | 
| 120 | 120 |      { | 
| 121 | -        if (!empty($options['post'])) { | |
| 121 | +        if (!empty($options[ 'post' ])) { | |
| 122 | 122 | $query->whereHas( | 
| 123 | 123 | 'posts', | 
| 124 | -                static function ($query) use ($options) { | |
| 125 | - ModelAbstract::whereTranslatableProperty($query, 'slug', $options['post']); | |
| 124 | +                static function($query) use ($options) { | |
| 125 | + ModelAbstract::whereTranslatableProperty($query, 'slug', $options[ 'post' ]); | |
| 126 | 126 | } | 
| 127 | 127 | ); | 
| 128 | 128 | } | 
| @@ -136,8 +136,8 @@ discard block | ||
| 136 | 136 | */ | 
| 137 | 137 | private function queryLimit(Builder $query, array $options) | 
| 138 | 138 |      { | 
| 139 | -        if (!empty($options['limit'])) { | |
| 140 | - $query->take($options['limit']); | |
| 139 | +        if (!empty($options[ 'limit' ])) { | |
| 140 | + $query->take($options[ 'limit' ]); | |
| 141 | 141 | } | 
| 142 | 142 | } | 
| 143 | 143 | |
| @@ -149,11 +149,11 @@ discard block | ||
| 149 | 149 | */ | 
| 150 | 150 | private function queryOrderBy(Builder $query, array $options) | 
| 151 | 151 |      { | 
| 152 | -        if (!empty($options['sort']) && \array_key_exists($options['sort'], static::$sortingOptions)) { | |
| 153 | -            if ($options['sort'] === 'random') { | |
| 152 | +        if (!empty($options[ 'sort' ]) && \array_key_exists($options[ 'sort' ], static::$sortingOptions)) { | |
| 153 | +            if ($options[ 'sort' ] === 'random') { | |
| 154 | 154 | $query->inRandomOrder(); | 
| 155 | 155 |              } else { | 
| 156 | -                [$sortField, $sortDirection] = explode(' ', $options['sort']); | |
| 156 | +                [ $sortField, $sortDirection ] = explode(' ', $options[ 'sort' ]); | |
| 157 | 157 | |
| 158 | 158 | $query->orderBy($sortField, $sortDirection); | 
| 159 | 159 | } | 
| @@ -168,10 +168,10 @@ discard block | ||
| 168 | 168 | */ | 
| 169 | 169 | protected function withRelation(Builder $query, array $options) | 
| 170 | 170 |      { | 
| 171 | -        if (!empty($options['fetchPosts'])) { | |
| 171 | +        if (!empty($options[ 'fetchPosts' ])) { | |
| 172 | 172 | $query->with( | 
| 173 | 173 | [ | 
| 174 | -                    'posts' => static function (HasMany $query) use ($options) { | |
| 174 | +                    'posts' => static function(HasMany $query) use ($options) { | |
| 175 | 175 | $query->isPublished(); | 
| 176 | 176 | |
| 177 | 177 | self::handleExceptions($query->getQuery(), $options); | 
| @@ -182,7 +182,7 @@ discard block | ||
| 182 | 182 | |
| 183 | 183 | $query->withCount( | 
| 184 | 184 | [ | 
| 185 | -                'posts' => static function ($query) use ($options) { | |
| 185 | +                'posts' => static function($query) use ($options) { | |
| 186 | 186 | $query->isPublished(); | 
| 187 | 187 | |
| 188 | 188 | self::handleExceptions($query, $options); | 
| @@ -205,12 +205,12 @@ discard block | ||
| 205 | 205 | */ | 
| 206 | 206 | protected static function handleExceptions(Builder $query, array $options) | 
| 207 | 207 |      { | 
| 208 | -        if (!empty($options['exceptPosts'])) { | |
| 209 | - PostListExceptionsTrait::handleExceptionsByPost($query, $options['exceptPosts']); | |
| 208 | +        if (!empty($options[ 'exceptPosts' ])) { | |
| 209 | + PostListExceptionsTrait::handleExceptionsByPost($query, $options[ 'exceptPosts' ]); | |
| 210 | 210 | } | 
| 211 | 211 | |
| 212 | -        if (!empty($options['exceptCategories'])) { | |
| 213 | - PostListExceptionsTrait::handleExceptionsByCategory($query, $options['exceptCategories']); | |
| 212 | +        if (!empty($options[ 'exceptCategories' ])) { | |
| 213 | + PostListExceptionsTrait::handleExceptionsByCategory($query, $options[ 'exceptCategories' ]); | |
| 214 | 214 | } | 
| 215 | 215 | } | 
| 216 | 216 | } | 
| @@ -41,7 +41,7 @@ discard block | ||
| 41 | 41 | * | 
| 42 | 42 | * @var array | 
| 43 | 43 | */ | 
| 44 | - public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel']; | |
| 44 | + public $implement = [ '@RainLab.Translate.Behaviors.TranslatableModel' ]; | |
| 45 | 45 | |
| 46 | 46 | /** | 
| 47 | 47 | * Translatable properties, indexed property will be available in queries | 
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 | ]; | 
| 71 | 71 | |
| 72 | 72 | public $morphToMany = [ | 
| 73 | - 'tags' => [Tag::class, 'name' => Tag::PIVOT_COLUMN] | |
| 73 | + 'tags' => [ Tag::class, 'name' => Tag::PIVOT_COLUMN ] | |
| 74 | 74 | ]; | 
| 75 | 75 | |
| 76 | 76 | /** | 
| @@ -146,7 +146,7 @@ discard block | ||
| 146 | 146 | /** | 
| 147 | 147 | * @var array | 
| 148 | 148 | */ | 
| 149 | - protected $slugs = ['slug' => 'title']; | |
| 149 | + protected $slugs = [ 'slug' => 'title' ]; | |
| 150 | 150 | |
| 151 | 151 | /** | 
| 152 | 152 | * @param Builder $query | 
| @@ -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 | 
| @@ -364,7 +364,7 @@ discard block | ||
| 364 | 364 | |
| 365 | 365 | $this->tagsPageUrl = $this->controller->pageUrl($this->tagsPage); | 
| 366 | 366 | |
| 367 | - $this->setUrls($tags, $this->tagPage, $this->controller, ['tag' => $this->urlProperty($tagComponent, 'tag')]); | |
| 367 | + $this->setUrls($tags, $this->tagPage, $this->controller, [ 'tag' => $this->urlProperty($tagComponent, 'tag') ]); | |
| 368 | 368 | } | 
| 369 | 369 | |
| 370 | 370 | /** | 
| @@ -406,18 +406,18 @@ discard block | ||
| 406 | 406 | |
| 407 | 407 | private function prepareVars() | 
| 408 | 408 |      { | 
| 409 | -        $this->tagPage = (string) $this->getProperty('tagPage'); | |
| 410 | -        $this->tagsPage = (string) $this->getProperty('tagsPage'); | |
| 409 | +        $this->tagPage = (string)$this->getProperty('tagPage'); | |
| 410 | +        $this->tagsPage = (string)$this->getProperty('tagsPage'); | |
| 411 | 411 | |
| 412 | 412 |          $this->orderBy = $this->getProperty('orderBy'); | 
| 413 | 413 |          $this->postSlug = $this->getProperty('postSlug'); | 
| 414 | -        $this->fetchPosts = (bool) $this->getProperty('fetchPosts'); | |
| 415 | -        $this->displayEmpty = (bool) $this->getProperty('displayEmpty'); | |
| 416 | -        $this->limit = (int) $this->getProperty('limit'); | |
| 417 | -        $this->exposeTotalCount = (bool) $this->getProperty('exposeTotalCount'); | |
| 418 | -        $this->enableTagFilter = (string) $this->getProperty('enableTagFilter'); | |
| 419 | -        $this->includeSeriesTags = (bool) $this->getProperty('includeSeriesTags'); | |
| 420 | -        $this->fetchSeriesPostCount = (bool) $this->getProperty('fetchSeriesPostCount'); | |
| 421 | -        $this->debugOutput = (bool) $this->getProperty('debugOutput'); | |
| 414 | +        $this->fetchPosts = (bool)$this->getProperty('fetchPosts'); | |
| 415 | +        $this->displayEmpty = (bool)$this->getProperty('displayEmpty'); | |
| 416 | +        $this->limit = (int)$this->getProperty('limit'); | |
| 417 | +        $this->exposeTotalCount = (bool)$this->getProperty('exposeTotalCount'); | |
| 418 | +        $this->enableTagFilter = (string)$this->getProperty('enableTagFilter'); | |
| 419 | +        $this->includeSeriesTags = (bool)$this->getProperty('includeSeriesTags'); | |
| 420 | +        $this->fetchSeriesPostCount = (bool)$this->getProperty('fetchSeriesPostCount'); | |
| 421 | +        $this->debugOutput = (bool)$this->getProperty('debugOutput'); | |
| 422 | 422 | } | 
| 423 | 423 | } | 
| @@ -87,13 +87,13 @@ | ||
| 87 | 87 | */ | 
| 88 | 88 | protected function getPostsQuery() | 
| 89 | 89 |      { | 
| 90 | -        $query = Post::whereHas('tags', function ($query) { | |
| 90 | +        $query = Post::whereHas('tags', function($query) { | |
| 91 | 91 |              $query->whereTranslatable('slug', $this->tag->slug); | 
| 92 | 92 | }); | 
| 93 | 93 | |
| 94 | 94 |          if ($this->includeSeriesPosts) { | 
| 95 | -            $query->orWhereHas('series', function ($query) { | |
| 96 | -                $query->whereHas('tags', function ($query) { | |
| 95 | +            $query->orWhereHas('series', function($query) { | |
| 96 | +                $query->whereHas('tags', function($query) { | |
| 97 | 97 |                      $query->whereTranslatable('slug', $this->tag->slug); | 
| 98 | 98 | }); | 
| 99 | 99 | }); | 
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 | */ | 
| 56 | 56 | public function onBulkDelete() | 
| 57 | 57 |      { | 
| 58 | -        if ($checkedIds = (array)post('checked', [])) { | |
| 58 | +        if ($checkedIds = (array)post('checked', [ ])) { | |
| 59 | 59 |              $delete = Tag::whereIn('id', $checkedIds)->delete(); | 
| 60 | 60 | } | 
| 61 | 61 | |
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | */ | 
| 78 | 78 | public function index_onRemoveOrphanedTags() | 
| 79 | 79 |      { | 
| 80 | -        if (!Tag::has('posts', 0)->has('series', 0)->count() ) { | |
| 80 | +        if (!Tag::has('posts', 0)->has('series', 0)->count()) { | |
| 81 | 81 | Flash::warning(e(trans(Plugin::LOCALIZATION_KEY . 'form.tags.no_orphaned_tags'))); | 
| 82 | 82 | |
| 83 | 83 | return; | 
| @@ -108,7 +108,7 @@ discard block | ||
| 108 | 108 | $tag = Tag::whereId($recordId)->first(); | 
| 109 | 109 | |
| 110 | 110 |          if ($tag !== null) { | 
| 111 | - $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.tags.edit_title', ['tag' => $tag->name]); | |
| 111 | + $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.tags.edit_title', [ 'tag' => $tag->name ]); | |
| 112 | 112 |          } else { | 
| 113 | 113 | $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.tags.tag_does_not_exist'); | 
| 114 | 114 | } | 
| @@ -56,7 +56,7 @@ | ||
| 56 | 56 | $series = SeriesModel::whereId($recordId)->first(); | 
| 57 | 57 | |
| 58 | 58 |          if ($series !== null) { | 
| 59 | - $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.edit_title', ['series' => $series->title]); | |
| 59 | + $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.edit_title', [ 'series' => $series->title ]); | |
| 60 | 60 |          } else { | 
| 61 | 61 | $this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.series_does_not_exist'); | 
| 62 | 62 | } | 
| @@ -55,8 +55,8 @@ discard block | ||
| 55 | 55 | */ | 
| 56 | 56 | private function dropSeries() | 
| 57 | 57 |      { | 
| 58 | -        Schema::table('rainlab_blog_posts', static function ($table) { | |
| 59 | - $table->dropForeign([Series::TABLE_NAME . '_id']); | |
| 58 | +        Schema::table('rainlab_blog_posts', static function($table) { | |
| 59 | + $table->dropForeign([ Series::TABLE_NAME . '_id' ]); | |
| 60 | 60 | $table->dropColumn(Series::TABLE_NAME . '_id'); | 
| 61 | 61 | }); | 
| 62 | 62 | |
| @@ -71,7 +71,7 @@ discard block | ||
| 71 | 71 |          if (!Schema::hasTable(Tag::TABLE_NAME)) { | 
| 72 | 72 | Schema::create( | 
| 73 | 73 | Tag::TABLE_NAME, | 
| 74 | -                static function ($table) { | |
| 74 | +                static function($table) { | |
| 75 | 75 | $table->engine = 'InnoDB'; | 
| 76 | 76 | |
| 77 | 77 |                      $table->increments('id'); | 
| @@ -85,12 +85,12 @@ discard block | ||
| 85 | 85 |          if (!Schema::hasTable(Tag::CROSS_REFERENCE_TABLE_NAME)) { | 
| 86 | 86 | Schema::create( | 
| 87 | 87 | Tag::CROSS_REFERENCE_TABLE_NAME, | 
| 88 | -                static function ($table) { | |
| 88 | +                static function($table) { | |
| 89 | 89 | $table->engine = 'InnoDB'; | 
| 90 | 90 | |
| 91 | 91 |                      $table->integer('tag_id')->unsigned()->nullable()->default(null); | 
| 92 | 92 |                      $table->integer('post_id')->unsigned()->nullable()->default(null); | 
| 93 | - $table->index(['tag_id', 'post_id']); | |
| 93 | + $table->index([ 'tag_id', 'post_id' ]); | |
| 94 | 94 |                      $table->foreign('tag_id', 'Tag reference')->references('id')->on(Tag::TABLE_NAME)->onDelete('cascade'); | 
| 95 | 95 |                      $table->foreign('post_id', 'Post reference')->references('id')->on('rainlab_blog_posts')->onDelete('cascade'); | 
| 96 | 96 | } | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 |          if (!Schema::hasTable(Series::TABLE_NAME)) { | 
| 107 | 107 | Schema::create( | 
| 108 | 108 | Series::TABLE_NAME, | 
| 109 | -                static function ($table) { | |
| 109 | +                static function($table) { | |
| 110 | 110 | $table->engine = 'InnoDB'; | 
| 111 | 111 | |
| 112 | 112 |                      $table->increments('id'); | 
| @@ -117,7 +117,7 @@ discard block | ||
| 117 | 117 | } | 
| 118 | 118 | ); | 
| 119 | 119 | |
| 120 | -            Schema::table('rainlab_blog_posts', function ($table) { | |
| 120 | +            Schema::table('rainlab_blog_posts', function($table) { | |
| 121 | 121 | $table->integer(Series::TABLE_NAME . '_id')->unsigned()->nullable()->default(null); | 
| 122 | 122 |                  $table->foreign(Series::TABLE_NAME . '_id')->references('id')->on(Series::TABLE_NAME)->onDelete('cascade'); | 
| 123 | 123 | }); | 
| @@ -20,7 +20,7 @@ discard block | ||
| 20 | 20 |      { | 
| 21 | 21 | return; | 
| 22 | 22 |          if (Schema::hasTable(Series::TABLE_NAME)) { | 
| 23 | -            Schema::table(Series::TABLE_NAME, static function ($table) { | |
| 23 | +            Schema::table(Series::TABLE_NAME, static function($table) { | |
| 24 | 24 |                  $table->text('description')->nullable()->change(); | 
| 25 | 25 | }); | 
| 26 | 26 | } | 
| @@ -33,7 +33,7 @@ discard block | ||
| 33 | 33 |      { | 
| 34 | 34 | return; | 
| 35 | 35 |          if (Schema::hasTable(Series::TABLE_NAME)) { | 
| 36 | -            Schema::table(Series::TABLE_NAME, static function ($table) { | |
| 36 | +            Schema::table(Series::TABLE_NAME, static function($table) { | |
| 37 | 37 |                  $table->string('description')->nullable()->change(); | 
| 38 | 38 | }); | 
| 39 | 39 | } |