@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | $result = $client->initIndex('docs')->search($query); |
| 33 | 33 | |
| 34 | - if ((int) array_get($result, 'nbHits') === 0) { |
|
| 34 | + if ((int)array_get($result, 'nbHits') === 0) { |
|
| 35 | 35 | $message->text = "погугли {$query}"; |
| 36 | 36 | return app(NewGoogleSearchMiddleware::class)->handle($message); |
| 37 | 37 | } |
@@ -40,25 +40,25 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $hits = new Collection($result['hits']); |
| 42 | 42 | |
| 43 | - $hits->unique(function ($row) { |
|
| 43 | + $hits->unique(function($row) { |
|
| 44 | 44 | return $row['h1']; |
| 45 | - })->map(function ($row) { |
|
| 46 | - $row['link'] = 'https://laravel.com/docs/5.2/' . $row['link']; |
|
| 45 | + })->map(function($row) { |
|
| 46 | + $row['link'] = 'https://laravel.com/docs/5.2/'.$row['link']; |
|
| 47 | 47 | return $row; |
| 48 | - })->take(3)->each(function ($row) use (&$response) { |
|
| 48 | + })->take(3)->each(function($row) use (&$response) { |
|
| 49 | 49 | $title = ''; |
| 50 | 50 | foreach (['h1', 'h2', 'h3', 'h4', 'h5'] as $tag) { |
| 51 | 51 | if (isset($row[$tag])) { |
| 52 | - $title .= ' ' . $row[$tag]; |
|
| 52 | + $title .= ' '.$row[$tag]; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $response .= "[*] [i][url={$row['link']}]{$title}[/url][/i]" . PHP_EOL; |
|
| 56 | + $response .= "[*] [i][url={$row['link']}]{$title}[/url][/i]".PHP_EOL; |
|
| 57 | 57 | }); |
| 58 | 58 | |
| 59 | 59 | if (!empty($response)) { |
| 60 | 60 | $message->answer(trans('search.results', [ |
| 61 | - 'results' => '[list]' . PHP_EOL . $response . PHP_EOL . '[/list]', |
|
| 61 | + 'results' => '[list]'.PHP_EOL.$response.PHP_EOL.'[/list]', |
|
| 62 | 62 | ])); |
| 63 | 63 | } |
| 64 | 64 | |