@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | if (!$this->property('disableUrlMapping') && \Request::isMethod('get') && $searchTerm) { |
| 210 | 210 | // add ?cats[] query string |
| 211 | 211 | $cats = Input::get('cat'); |
| 212 | - $query = http_build_query(['cat' => $cats]); |
|
| 212 | + $query = http_build_query([ 'cat' => $cats ]); |
|
| 213 | 213 | $query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $query); |
| 214 | 214 | $query = !empty($query) ? '?' . $query : ''; |
| 215 | 215 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $currentPage = $this->property('pageNumber'); |
| 232 | 232 | |
| 233 | 233 | if ($currentPage > ($lastPage = $this->posts->lastPage()) && $currentPage > 1) { |
| 234 | - return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage])); |
|
| 234 | + return Redirect::to($this->currentPageUrl([ $pageNumberParam => $lastPage ])); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -264,41 +264,41 @@ discard block |
||
| 264 | 264 | protected function listPosts() |
| 265 | 265 | { |
| 266 | 266 | // get posts in excluded category |
| 267 | - $blockedPosts = []; |
|
| 268 | - $categories = BlogCategory::with(['posts' => function ($q) { |
|
| 267 | + $blockedPosts = [ ]; |
|
| 268 | + $categories = BlogCategory::with([ 'posts' => function($q) { |
|
| 269 | 269 | $q->select('post_id'); |
| 270 | - }]) |
|
| 270 | + } ]) |
|
| 271 | 271 | ->whereIn('id', $this->property('excludeCategories')) |
| 272 | 272 | ->get(); |
| 273 | 273 | |
| 274 | - $categories->each(function ($item) use (&$blockedPosts) { |
|
| 275 | - $item->posts->each(function ($item) use (&$blockedPosts) { |
|
| 276 | - $blockedPosts[] = $item->post_id; |
|
| 274 | + $categories->each(function($item) use (&$blockedPosts) { |
|
| 275 | + $item->posts->each(function($item) use (&$blockedPosts) { |
|
| 276 | + $blockedPosts[ ] = $item->post_id; |
|
| 277 | 277 | }); |
| 278 | 278 | }); |
| 279 | 279 | |
| 280 | 280 | // get only posts from included categories |
| 281 | - $allowedPosts = []; |
|
| 282 | - $categories = BlogCategory::with(['posts' => function ($q) { |
|
| 281 | + $allowedPosts = [ ]; |
|
| 282 | + $categories = BlogCategory::with([ 'posts' => function($q) { |
|
| 283 | 283 | $q->select('post_id'); |
| 284 | - }]) |
|
| 284 | + } ]) |
|
| 285 | 285 | ->whereIn('id', $this->property('includeCategories')) |
| 286 | 286 | ->get(); |
| 287 | 287 | |
| 288 | - $categories->each(function ($item) use (&$allowedPosts) { |
|
| 289 | - $item->posts->each(function ($item) use (&$allowedPosts) { |
|
| 290 | - $allowedPosts[] = $item->post_id; |
|
| 288 | + $categories->each(function($item) use (&$allowedPosts) { |
|
| 289 | + $item->posts->each(function($item) use (&$allowedPosts) { |
|
| 290 | + $allowedPosts[ ] = $item->post_id; |
|
| 291 | 291 | }); |
| 292 | 292 | }); |
| 293 | 293 | |
| 294 | 294 | // Filter posts |
| 295 | - $posts = BlogPost::with(['categories' => function ($q) { |
|
| 295 | + $posts = BlogPost::with([ 'categories' => function($q) { |
|
| 296 | 296 | $q->whereNotIn('id', $this->property('excludeCategories')); |
| 297 | 297 | $q->whereIn('id', $this->property('includeCategories')); |
| 298 | - }]) |
|
| 298 | + } ]) |
|
| 299 | 299 | ->whereNotIn('id', $blockedPosts) |
| 300 | 300 | ->whereIn('id', $allowedPosts) |
| 301 | - ->where(function ($q) { |
|
| 301 | + ->where(function($q) { |
|
| 302 | 302 | $q->where('title', 'LIKE', "%{$this->searchTerm}%") |
| 303 | 303 | ->orWhere('content', 'LIKE', "%{$this->searchTerm}%") |
| 304 | 304 | ->orWhere('excerpt', 'LIKE', "%{$this->searchTerm}%"); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | // filter categories |
| 308 | 308 | $cat = Input::get('cat'); |
| 309 | 309 | if ($cat) { |
| 310 | - $cat = is_array($cat) ? $cat : [$cat]; |
|
| 310 | + $cat = is_array($cat) ? $cat : [ $cat ]; |
|
| 311 | 311 | $posts->filterCategories($cat); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | /* |
| 322 | 322 | * Add a "url" helper attribute for linking to each post and category |
| 323 | 323 | */ |
| 324 | - $posts->each(function ($post) { |
|
| 324 | + $posts->each(function($post) { |
|
| 325 | 325 | $post->setUrl($this->postPage, $this->controller); |
| 326 | 326 | |
| 327 | - $post->categories->each(function ($category) { |
|
| 327 | + $post->categories->each(function($category) { |
|
| 328 | 328 | $category->setUrl($this->categoryPage, $this->controller); |
| 329 | 329 | }); |
| 330 | 330 | |