Completed
Push — master ( 3b785c...3b8bf5 )
by Pascal
10:50
created
components/SearchResult.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
         if (!$this->property('disableUrlMapping') && \Request::isMethod('get') && $searchTerm) {
215 215
             // add ?cats[] query string
216 216
             $cats = Input::get('cat');
217
-            $query = http_build_query(['cat' => $cats]);
217
+            $query = http_build_query([ 'cat' => $cats ]);
218 218
             $query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $query);
219
-            $query = !empty($query) ? '?' . $query : '';
219
+            $query = !empty($query) ? '?'.$query : '';
220 220
 
221 221
             return Redirect::to(
222 222
                 $this->currentPageUrl([
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             $currentPage = $this->property('pageNumber');
237 237
 
238 238
             if ($currentPage > ($lastPage = $this->posts->lastPage()) && $currentPage > 1) {
239
-                return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
239
+                return Redirect::to($this->currentPageUrl([ $pageNumberParam => $lastPage ]));
240 240
             }
241 241
         }
242 242
     }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     {
271 271
         // Filter posts
272 272
         $posts = BlogPost::with([
273
-            'categories' => function ($q) {
273
+            'categories' => function($q) {
274 274
                 if (!is_null($this->property('excludeCategories'))) {
275 275
                     $q->whereNotIn('id', $this->property('excludeCategories'));
276 276
                 }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                 }
280 280
             }
281 281
         ])
282
-            ->where(function ($q) {
282
+            ->where(function($q) {
283 283
                 $q->where('title', 'LIKE', "%{$this->searchTerm}%")
284 284
                     ->orWhere('content', 'LIKE', "%{$this->searchTerm}%")
285 285
                     ->orWhere('excerpt', 'LIKE', "%{$this->searchTerm}%");
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         // filter categories
289 289
         $cat = Input::get('cat');
290 290
         if ($cat) {
291
-            $cat = is_array($cat) ? $cat : [$cat];
291
+            $cat = is_array($cat) ? $cat : [ $cat ];
292 292
             $posts->filterCategories($cat);
293 293
         }
294 294
 
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
         /*
315 315
          * Add a "url" helper attribute for linking to each post and category
316 316
          */
317
-        $posts->each(function ($post) {
317
+        $posts->each(function($post) {
318 318
             $post->setUrl($this->postPage, $this->controller);
319 319
 
320
-            $post->categories->each(function ($category) {
320
+            $post->categories->each(function($category) {
321 321
                 $category->setUrl($this->categoryPage, $this->controller);
322 322
             });
323 323
 
@@ -336,19 +336,19 @@  discard block
 block discarded – undo
336 336
     protected function getPostIdsByCategories($ids = null)
337 337
     {
338 338
         if (is_null($ids) || !is_array($ids)) {
339
-            return [];
339
+            return [ ];
340 340
         }
341 341
 
342
-        $posts = [];
343
-        $categories = BlogCategory::with(['posts' => function ($q) {
342
+        $posts = [ ];
343
+        $categories = BlogCategory::with([ 'posts' => function($q) {
344 344
             $q->select('post_id');
345
-        }])
345
+        } ])
346 346
             ->whereIn('id', $ids)
347 347
             ->get();
348 348
 
349
-        $categories->each(function ($item) use (&$posts) {
350
-            $item->posts->each(function ($item) use (&$posts) {
351
-                $posts[] = $item->post_id;
349
+        $categories->each(function($item) use (&$posts) {
350
+            $item->posts->each(function($item) use (&$posts) {
351
+                $posts[ ] = $item->post_id;
352 352
             });
353 353
         });
354 354
 
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
             $searchTerm = preg_quote($this->searchTerm, '|');
365 365
 
366 366
             // apply highlight
367
-            $post->title = preg_replace('|(' . $searchTerm . ')|iu', '<mark>$1</mark>', $post->title);
368
-            $post->excerpt = preg_replace('|(' . $searchTerm . ')|iu', '<mark>$1</mark>', $post->excerpt);
367
+            $post->title = preg_replace('|('.$searchTerm.')|iu', '<mark>$1</mark>', $post->title);
368
+            $post->excerpt = preg_replace('|('.$searchTerm.')|iu', '<mark>$1</mark>', $post->excerpt);
369 369
 
370 370
             $post->content_html = preg_replace(
371
-                '~(?![^<>]*>)(' . $searchTerm . ')~ismu',
371
+                '~(?![^<>]*>)('.$searchTerm.')~ismu',
372 372
                 '<mark>$1</mark>',
373 373
                 $post->content_html
374 374
             );
Please login to merge, or discard this patch.