@@ -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 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | Schema::create( |
| 70 | 70 | Tag::TABLE_NAME, |
| 71 | - function ($table) { |
|
| 71 | + function($table) { |
|
| 72 | 72 | $table->engine = 'InnoDB'; |
| 73 | 73 | |
| 74 | 74 | $table->increments('id'); |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | Schema::create( |
| 82 | 82 | Tag::CROSS_REFERENCE_TABLE_NAME, |
| 83 | - function ($table) { |
|
| 83 | + function($table) { |
|
| 84 | 84 | $table->engine = 'InnoDB'; |
| 85 | 85 | |
| 86 | 86 | $table->integer('tag_id')->unsigned()->nullable()->default(null); |
| 87 | 87 | $table->integer('post_id')->unsigned()->nullable()->default(null); |
| 88 | - $table->index(['tag_id', 'post_id']); |
|
| 88 | + $table->index([ 'tag_id', 'post_id' ]); |
|
| 89 | 89 | $table->foreign('tag_id', 'Tag reference')->references('id')->on(Tag::TABLE_NAME)->onDelete('cascade'); |
| 90 | 90 | $table->foreign('post_id', 'Post reference')->references('id')->on('rainlab_blog_posts')->onDelete('cascade'); |
| 91 | 91 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | Schema::create( |
| 101 | 101 | Series::TABLE_NAME, |
| 102 | - function ($table) { |
|
| 102 | + function($table) { |
|
| 103 | 103 | $table->engine = 'InnoDB'; |
| 104 | 104 | |
| 105 | 105 | $table->increments('id'); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | - Schema::table('rainlab_blog_posts', function ($table) { |
|
| 113 | + Schema::table('rainlab_blog_posts', function($table) { |
|
| 114 | 114 | $table->integer(Series::TABLE_NAME . '_id')->unsigned()->nullable()->default(null); |
| 115 | 115 | $table->foreign(Series::TABLE_NAME . '_id')->references('id')->on(Series::TABLE_NAME)->onDelete('cascade'); |
| 116 | 116 | }); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function onBulkDelete() |
| 56 | 56 | { |
| 57 | - if (($checkedIds = (array)post('checked', []))) { |
|
| 57 | + if (($checkedIds = (array)post('checked', [ ]))) { |
|
| 58 | 58 | $delete = Tag::whereIn('id', $checkedIds)->delete(); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $this->asExtension('FormController')->update(post('record_id')); |
| 119 | 119 | |
| 120 | - $this->vars['recordId'] = post('record_id'); |
|
| 120 | + $this->vars[ 'recordId' ] = post('record_id'); |
|
| 121 | 121 | |
| 122 | 122 | return $this->makePartial('tag_update_modal_form'); |
| 123 | 123 | } |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | use Backend\Behaviors\FormController; |
| 11 | 11 | use Backend\Behaviors\ListController; |
| 12 | 12 | use October\Rain\Exception\SystemException; |
| 13 | -use October\Rain\Flash\FlashBag; |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * Class Tags |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | /** |
| 32 | 32 | * @var array |
| 33 | 33 | */ |
| 34 | - protected $slugs = ['slug' => 'name']; |
|
| 34 | + protected $slugs = [ 'slug' => 'name' ]; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Relations |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @var array Require the RainLab.Blog plugin |
| 37 | 37 | */ |
| 38 | - public $require = [self::REQUIRED_PLUGIN]; |
|
| 38 | + public $require = [ self::REQUIRED_PLUGIN ]; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Returns information about this plugin |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | public function registerNavigation() |
| 92 | 92 | { |
| 93 | 93 | // Extend the navigation |
| 94 | - Event::listen('backend.menu.extendItems', function ($manager) { |
|
| 94 | + Event::listen('backend.menu.extendItems', function($manager) { |
|
| 95 | 95 | $manager->addSideMenuItems(self::REQUIRED_PLUGIN, 'blog', [ |
| 96 | 96 | 'series' => [ |
| 97 | 97 | 'label' => self::LOCALIZATION_KEY . 'navigation.series', |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | private function extendModel() |
| 119 | 119 | { |
| 120 | - PostModel::extend(function ($model) { |
|
| 121 | - $model->belongsToMany['tags'] = [ |
|
| 120 | + PostModel::extend(function($model) { |
|
| 121 | + $model->belongsToMany[ 'tags' ] = [ |
|
| 122 | 122 | Tag::class, |
| 123 | 123 | 'table' => Tag::CROSS_REFERENCE_TABLE_NAME, |
| 124 | 124 | 'order' => 'name' |
| 125 | 125 | ]; |
| 126 | 126 | |
| 127 | - $model->belongsTo['series'] = [ |
|
| 127 | + $model->belongsTo[ 'series' ] = [ |
|
| 128 | 128 | Series::class, |
| 129 | 129 | 'key' => Series::TABLE_NAME . "_id" |
| 130 | 130 | ]; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | private function extendPostsController() |
| 138 | 138 | { |
| 139 | - PostsController::extendFormFields(function ($form, $model) { |
|
| 139 | + PostsController::extendFormFields(function($form, $model) { |
|
| 140 | 140 | if (!$model instanceof PostModel) { |
| 141 | 141 | return; |
| 142 | 142 | } |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | $tab = self::LOCALIZATION_KEY . 'navigation.taxonomy'; |
| 145 | 145 | |
| 146 | 146 | $categoriesConfig = $form->getField('categories')->config; |
| 147 | - $categoriesConfig['tab'] = $tab; |
|
| 148 | - $categoriesConfig['mode'] = 'relation'; |
|
| 149 | - $categoriesConfig['type'] = 'taglist'; |
|
| 150 | - $categoriesConfig['label'] = 'Categories'; |
|
| 151 | - $categoriesConfig['comment'] = "rainlab.blog::lang.post.categories_comment"; |
|
| 152 | - $categoriesConfig['placeholder'] = self::LOCALIZATION_KEY . 'placeholders.tags'; |
|
| 153 | - unset($categoriesConfig['commentAbove']); |
|
| 147 | + $categoriesConfig[ 'tab' ] = $tab; |
|
| 148 | + $categoriesConfig[ 'mode' ] = 'relation'; |
|
| 149 | + $categoriesConfig[ 'type' ] = 'taglist'; |
|
| 150 | + $categoriesConfig[ 'label' ] = 'Categories'; |
|
| 151 | + $categoriesConfig[ 'comment' ] = "rainlab.blog::lang.post.categories_comment"; |
|
| 152 | + $categoriesConfig[ 'placeholder' ] = self::LOCALIZATION_KEY . 'placeholders.tags'; |
|
| 153 | + unset($categoriesConfig[ 'commentAbove' ]); |
|
| 154 | 154 | |
| 155 | 155 | $form->removeField('categories'); |
| 156 | 156 | |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | ]); |
| 181 | 181 | }); |
| 182 | 182 | |
| 183 | - PostsController::extend(function (Controller $controller) { |
|
| 184 | - $controller->implement[] = RelationController::class; |
|
| 183 | + PostsController::extend(function(Controller $controller) { |
|
| 184 | + $controller->implement[ ] = RelationController::class; |
|
| 185 | 185 | $relationConfig = '$/' . self::DIRECTORY_KEY . '/controllers/series/config_posts_relation.yaml'; |
| 186 | 186 | |
| 187 | 187 | if (property_exists($controller, 'relationConfig')) { |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | private function extendCategoriesController() |
| 202 | 202 | { |
| 203 | - CategoriesController::extend(function (Controller $controller) { |
|
| 204 | - $controller->implement[] = RelationController::class; |
|
| 203 | + CategoriesController::extend(function(Controller $controller) { |
|
| 204 | + $controller->implement[ ] = RelationController::class; |
|
| 205 | 205 | $relationConfig = '$/' . self::DIRECTORY_KEY . '/controllers/category/config_relation.yaml'; |
| 206 | 206 | |
| 207 | 207 | if (property_exists($controller, 'relationConfig')) { |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @var Collection | array |
| 20 | 20 | */ |
| 21 | - public $posts = []; |
|
| 21 | + public $posts = [ ]; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Reference to the page name for linking to posts |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | protected function prepareVars() |
| 101 | 101 | { |
| 102 | - $this->postParam = $this->page['postParam'] = $this->property('postParam'); |
|
| 102 | + $this->postParam = $this->page[ 'postParam' ] = $this->property('postParam'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public function getPostPageOptions() |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | select count(*) |
| 138 | 138 | from `ginopane_blogtaxonomy_post_tag` |
| 139 | 139 | where `ginopane_blogtaxonomy_post_tag`.`post_id` = `rainlab_blog_posts`.`id` |
| 140 | - and `ginopane_blogtaxonomy_post_tag`.`tag_id` in ('.implode(', ', $tagIds).') |
|
| 140 | + and `ginopane_blogtaxonomy_post_tag`.`tag_id` in ('.implode(', ', $tagIds) . ') |
|
| 141 | 141 | )'); |
| 142 | 142 | |
| 143 | 143 | $key = $this->property('orderBy') ?: $subQuery; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $posts->each( |
| 158 | 158 | function($post) |
| 159 | 159 | { |
| 160 | - $post->setUrl($this->postPage,$this->controller); |
|
| 160 | + $post->setUrl($this->postPage, $this->controller); |
|
| 161 | 161 | } |
| 162 | 162 | ); |
| 163 | 163 | |
@@ -121,8 +121,9 @@ |
||
| 121 | 121 | ->first(); |
| 122 | 122 | |
| 123 | 123 | // Abort if there is no source, or it has no tags |
| 124 | - if (!$post || (!$tagIds = $post->tags->lists('id'))) |
|
| 125 | - return; |
|
| 124 | + if (!$post || (!$tagIds = $post->tags->lists('id'))) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 126 | 127 | |
| 127 | 128 | // Start building our query for related posts |
| 128 | 129 | $query = Post::isPublished() |
@@ -132,7 +132,7 @@ |
||
| 132 | 132 | |
| 133 | 133 | $series->setUrl($this->seriesPage, $this->controller); |
| 134 | 134 | |
| 135 | - $series->posts->each(function ($post) { |
|
| 135 | + $series->posts->each(function($post) { |
|
| 136 | 136 | $post->setUrl($this->postPage, $this->controller); |
| 137 | 137 | }); |
| 138 | 138 | } |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace GinoPane\BlogTaxonomy\Components; |
| 4 | 4 | |
| 5 | -use DB; |
|
| 6 | 5 | use Cms\Classes\Page; |
| 7 | 6 | use Cms\Classes\ComponentBase; |
| 8 | 7 | use GinoPane\BlogTaxonomy\Plugin; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @var Collection | array |
| 23 | 23 | */ |
| 24 | - public $tags = []; |
|
| 24 | + public $tags = [ ]; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Reference to the page name for linking to tags page |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $this->tagsPage = $this->property('tagsPage', ''); |
| 128 | 128 | $this->orderBy = $this->property('orderBy', 'name asc'); |
| 129 | 129 | $this->displayEmpty = $this->property('displayEmpty', false); |
| 130 | - $this->limit = $this->property('limit', 0); |
|
| 130 | + $this->limit = $this->property('limit', 0); |
|
| 131 | 131 | |
| 132 | 132 | $this->tags = $this->listTags(); |
| 133 | 133 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * @param $items |
| 30 | - * @param $urlPage |
|
| 30 | + * @param string $urlPage |
|
| 31 | 31 | * @param $controller |
| 32 | 32 | */ |
| 33 | 33 | public function setUrls($items, $urlPage, $controller) |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $post->setUrl($this->postPage, $this->controller); |
| 50 | 50 | |
| 51 | 51 | if ($post && $post->categories->count()) { |
| 52 | - $post->categories->each(function ($category) { |
|
| 52 | + $post->categories->each(function($category) { |
|
| 53 | 53 | $category->setUrl($this->categoryPage, $this->controller); |
| 54 | 54 | }); |
| 55 | 55 | } |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return mixed |
| 20 | 20 | */ |
| 21 | - public function scopeListFrontend($query, array $options = []) |
|
| 21 | + public function scopeListFrontend($query, array $options = [ ]) |
|
| 22 | 22 | { |
| 23 | - if (in_array($options['sort'], array_keys(self::$sortingOptions))) { |
|
| 24 | - if ($options['sort'] == 'random') { |
|
| 23 | + if (in_array($options[ 'sort' ], array_keys(self::$sortingOptions))) { |
|
| 24 | + if ($options[ 'sort' ] == 'random') { |
|
| 25 | 25 | $query->inRandomOrder(); |
| 26 | 26 | } else { |
| 27 | - list($sortField, $sortDirection) = explode(' ', $options['sort']); |
|
| 27 | + list($sortField, $sortDirection) = explode(' ', $options[ 'sort' ]); |
|
| 28 | 28 | |
| 29 | 29 | if ($sortField == 'posts_count') { |
| 30 | 30 | $query->withCount('posts'); |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if (empty($options['displayEmpty'])) { |
|
| 37 | + if (empty($options[ 'displayEmpty' ])) { |
|
| 38 | 38 | $query->has('posts'); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // Limit the number of results |
| 42 | - if (!empty($options['limit'])) { |
|
| 43 | - $query->take($options['limit']); |
|
| 42 | + if (!empty($options[ 'limit' ])) { |
|
| 43 | + $query->take($options[ 'limit' ]); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return $query->with([ |
| 47 | - 'posts' => function($query){ |
|
| 47 | + 'posts' => function($query) { |
|
| 48 | 48 | $query->isPublished(); |
| 49 | 49 | } |
| 50 | 50 | ] |