Completed
Push — master ( 4fefc5...f03307 )
by Pascal
08:38 queued 03:37
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
     }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     protected function listPosts()
270 270
     {
271 271
         // Filter posts
272
-        $posts = BlogPost::whereHas('categories', function ($q) {
272
+        $posts = BlogPost::whereHas('categories', function($q) {
273 273
                 if (!is_null($this->property('excludeCategories'))) {
274 274
                     $q->whereNotIn('id', $this->property('excludeCategories'));
275 275
                 }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                     $q->whereIn('id', $this->property('includeCategories'));
278 278
                 }
279 279
             })
280
-            ->where(function ($q) {
280
+            ->where(function($q) {
281 281
                 $q->where('title', 'LIKE', "%{$this->searchTerm}%")
282 282
                     ->orWhere('content', 'LIKE', "%{$this->searchTerm}%")
283 283
                     ->orWhere('excerpt', 'LIKE', "%{$this->searchTerm}%");
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         // filter categories
287 287
         $cat = Input::get('cat');
288 288
         if ($cat) {
289
-            $cat = is_array($cat) ? $cat : [$cat];
289
+            $cat = is_array($cat) ? $cat : [ $cat ];
290 290
             $posts->filterCategories($cat);
291 291
         }
292 292
 
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
         /*
301 301
          * Add a "url" helper attribute for linking to each post and category
302 302
          */
303
-        $posts->each(function ($post) {
303
+        $posts->each(function($post) {
304 304
             $post->setUrl($this->postPage, $this->controller);
305 305
 
306
-            $post->categories->each(function ($category) {
306
+            $post->categories->each(function($category) {
307 307
                 $category->setUrl($this->categoryPage, $this->controller);
308 308
             });
309 309
 
@@ -322,19 +322,19 @@  discard block
 block discarded – undo
322 322
     protected function getPostIdsByCategories($ids = null)
323 323
     {
324 324
         if (is_null($ids) || !is_array($ids)) {
325
-            return [];
325
+            return [ ];
326 326
         }
327 327
 
328
-        $posts = [];
329
-        $categories = BlogCategory::with(['posts' => function ($q) {
328
+        $posts = [ ];
329
+        $categories = BlogCategory::with([ 'posts' => function($q) {
330 330
             $q->select('post_id');
331
-        }])
331
+        } ])
332 332
             ->whereIn('id', $ids)
333 333
             ->get();
334 334
 
335
-        $categories->each(function ($item) use (&$posts) {
336
-            $item->posts->each(function ($item) use (&$posts) {
337
-                $posts[] = $item->post_id;
335
+        $categories->each(function($item) use (&$posts) {
336
+            $item->posts->each(function($item) use (&$posts) {
337
+                $posts[ ] = $item->post_id;
338 338
             });
339 339
         });
340 340
 
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
             $searchTerm = preg_quote($this->searchTerm, '|');
351 351
 
352 352
             // apply highlight
353
-            $post->title = preg_replace('|(' . $searchTerm . ')|iu', '<mark>$1</mark>', $post->title);
354
-            $post->excerpt = preg_replace('|(' . $searchTerm . ')|iu', '<mark>$1</mark>', $post->excerpt);
353
+            $post->title = preg_replace('|('.$searchTerm.')|iu', '<mark>$1</mark>', $post->title);
354
+            $post->excerpt = preg_replace('|('.$searchTerm.')|iu', '<mark>$1</mark>', $post->excerpt);
355 355
 
356 356
             $post->content_html = preg_replace(
357
-                '~(?![^<>]*>)(' . $searchTerm . ')~ismu',
357
+                '~(?![^<>]*>)('.$searchTerm.')~ismu',
358 358
                 '<mark>$1</mark>',
359 359
                 $post->content_html
360 360
             );
Please login to merge, or discard this patch.