Passed
Branch master (4bae09)
by Gino
02:07
created
updates/create_taxonomies_tables.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
controllers/Tags.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
models/Tag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
models/Series.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     /**
84 84
      * @var array
85 85
      */
86
-    protected $slugs = ['slug' => 'title'];
86
+    protected $slugs = [ 'slug' => 'title' ];
87 87
 
88 88
     /**
89 89
      * @return mixed
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
     public function scopeListFrontend($query, $options)
119 119
     {
120 120
         // Default options
121
-        array_merge(['sort' => 'created_at'], $options);
121
+        array_merge([ 'sort' => 'created_at' ], $options);
122 122
 
123 123
         // Sorting
124 124
         // @see \RainLab\Blog\Models\Post::scopeListFrontEnd()
125
-        if (!is_array($options['sort'])) {
126
-            $options['sort'] = [$options['sort']];
125
+        if (!is_array($options[ 'sort' ])) {
126
+            $options[ 'sort' ] = [ $options[ 'sort' ] ];
127 127
         }
128 128
 
129
-        foreach ($options['sort'] as $sort) {
129
+        foreach ($options[ 'sort' ] as $sort) {
130 130
             if (in_array($sort, array_keys(self::$sortingOptions))) {
131 131
                 $parts = explode(' ', $sort);
132 132
                 if (count($parts) < 2) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
         return $query->with(
144 144
             [
145
-                'posts' => function($query){
145
+                'posts' => function($query) {
146 146
                     $query->isPublished();
147 147
                 }
148 148
             ]
Please login to merge, or discard this patch.
Plugin.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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')) {
Please login to merge, or discard this patch.
components/TagPosts.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public $lastPage;
63 63
 
64
-     /**
65
-     * Reference to the page name for linking to posts.
66
-     * @var string
67
-     */
64
+        /**
65
+         * Reference to the page name for linking to posts.
66
+         * @var string
67
+         */
68 68
     public $postPage;
69 69
 
70 70
     /**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             ->orWhere('slug', $this->property('tag'))
163 163
             ->with(['posts' => function($posts) {
164 164
                 $posts->skip($this->resultsPerPage * ($this->currentPage - 1))
165
-                      ->take($this->resultsPerPage);
165
+                        ->take($this->resultsPerPage);
166 166
             }])
167 167
             ->first();
168 168
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * @var Collection | array
26 26
      */
27
-    public $posts = [];
27
+    public $posts = [ ];
28 28
 
29 29
     /**
30 30
      * @var integer             The total number of posts with the tag
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function onRun()
142 142
     {
143
-        $this->postPage = $this->page['postPage'] = $this->property('postPage');
144
-        $this->categoryPage = $this->page['categoryPage'] = $this->property('categoryPage');
143
+        $this->postPage = $this->page[ 'postPage' ] = $this->property('postPage');
144
+        $this->categoryPage = $this->page[ 'categoryPage' ] = $this->property('categoryPage');
145 145
 
146 146
         $this->onLoadPage($this->property('page'));
147 147
     }
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
         // Query the tag with it's posts
161 161
         $this->tag = Tag::where('name', $this->property('tag'))
162 162
             ->orWhere('slug', $this->property('tag'))
163
-            ->with(['posts' => function($posts) {
163
+            ->with([ 'posts' => function($posts) {
164 164
                 $posts->skip($this->resultsPerPage * ($this->currentPage - 1))
165 165
                       ->take($this->resultsPerPage);
166
-            }])
166
+            } ])
167 167
             ->first();
168 168
 
169 169
         // Store the posts in a better container
170
-        if(empty($this->tag)) {
170
+        if (empty($this->tag)) {
171 171
             $this->posts = null;
172 172
             $this->postsOnPage = 0;
173 173
         } else {
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 
177 177
             // Add a "url" helper attribute for linking to each post
178 178
             $this->posts->each(function($post) {
179
-                $post->setUrl($this->postPage,$this->controller);
179
+                $post->setUrl($this->postPage, $this->controller);
180 180
 
181
-                if($post->categories->count()) {
182
-                    $post->categories->each(function($category){
181
+                if ($post->categories->count()) {
182
+                    $post->categories->each(function($category) {
183 183
                         $category->setUrl($this->categoryPage, $this->controller);
184 184
                     });
185 185
                 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -218,8 +218,12 @@
 block discarded – undo
218 218
         $this->lastPage = ceil($this->totalPosts / $this->resultsPerPage);
219 219
 
220 220
         // Prevent the current page from being one that doesn't exist
221
-        if ($this->currentPage < 1) $this->currentPage = 1;
222
-        if ($this->currentPage > $this->lastPage) $this->currentPage = $this->lastPage;
221
+        if ($this->currentPage < 1) {
222
+            $this->currentPage = 1;
223
+        }
224
+        if ($this->currentPage > $this->lastPage) {
225
+            $this->currentPage = $this->lastPage;
226
+        }
223 227
 
224 228
         // Calculate the previous page
225 229
         $this->previousPage = $this->currentPage > 1
Please login to merge, or discard this patch.
components/SeriesPosts.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $this->prepareVars();
134 134
 
135 135
         // load posts
136
-        $this->series = $this->page['series'] = $this->listSeries();
136
+        $this->series = $this->page[ 'series' ] = $this->listSeries();
137 137
 
138 138
         if (is_null($this->series)) {
139 139
             $this->setStatusCode(404);
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
      */
147 147
     protected function prepareVars()
148 148
     {
149
-        $this->noPostsMessage = $this->page['noPostsMessage'] = $this->property('noPostsMessage');
150
-        $this->sortOrder = $this->page['sortOrder'] = $this->property('sortOrder');
149
+        $this->noPostsMessage = $this->page[ 'noPostsMessage' ] = $this->property('noPostsMessage');
150
+        $this->sortOrder = $this->page[ 'sortOrder' ] = $this->property('sortOrder');
151 151
 
152 152
         // Page links
153
-        $this->postPage = $this->page['postPage' ] = $this->property('postPage');
154
-        $this->categoryPage = $this->page['categoryPage'] = $this->property('categoryPage');
153
+        $this->postPage = $this->page[ 'postPage' ] = $this->property('postPage');
154
+        $this->categoryPage = $this->page[ 'categoryPage' ] = $this->property('categoryPage');
155 155
     }
156 156
 
157 157
     /**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // get serie
164 164
         $slug = $this->property('slug');
165 165
         $series = Series::with([
166
-            'posts' => function ($query) {
166
+            'posts' => function($query) {
167 167
                 $query->isPublished();
168 168
 
169 169
                 $sort = $this->property('sortOrder');
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                  * @see \RainLab\Blog\Models\Post::scopeListFrontEnd()
173 173
                  */
174 174
                 if (!is_array($sort)) {
175
-                    $sort = [$sort];
175
+                    $sort = [ $sort ];
176 176
                 }
177 177
 
178 178
                 foreach ($sort as $sorting) {
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
         // Add a "url" helper attribute for linking to each post and category
198 198
         if ($series && $series->posts->count()) {
199
-            $series->posts->each([$this, 'setUrls']);
199
+            $series->posts->each([ $this, 'setUrls' ]);
200 200
         }
201 201
 
202 202
         return $series;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         $post->setUrl($this->postPage, $this->controller);
212 212
 
213 213
         if ($post && $post->categories->count()) {
214
-            $post->categories->each(function ($category) {
214
+            $post->categories->each(function($category) {
215 215
                 $category->setUrl($this->categoryPage, $this->controller);
216 216
             });
217 217
         }
Please login to merge, or discard this patch.
components/TagList.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
     /**
19 19
      * @var Collection | array
20 20
      */
21
-    public $tags = [];
21
+    public $tags = [ ];
22 22
 
23 23
     /**
24 24
      * Reference to the page name for linking to series.
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,8 +130,9 @@
 block discarded – undo
130 130
         $query->orderBy($key, $this->property('direction'));
131 131
 
132 132
         // Limit the number of results
133
-        if ($take = intval($this->property('results')))
134
-            $query->take($take);
133
+        if ($take = intval($this->property('results'))) {
134
+                    $query->take($take);
135
+        }
135 136
 
136 137
         $tags = $query->get();
137 138
 
Please login to merge, or discard this patch.
components/RelatedPosts.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,8 +121,9 @@
 block discarded – undo
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()
Please login to merge, or discard this patch.