1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NovaNavigaAdPreview\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use Illuminate\Support\Facades\Response; |
7
|
|
|
use Illuminate\Support\Str; |
8
|
|
|
use NavigaAdClient\NavigaAd; |
9
|
|
|
use NavigaAdClient\Responses\PaginatedResponse; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class ListRequestController extends Controller |
12
|
|
|
{ |
13
|
1 |
|
public function __invoke(Request $request) |
14
|
|
|
{ |
15
|
1 |
|
$request->validate([ |
16
|
1 |
|
'page' => ['nullable', 'integer', 'min:1'], |
17
|
1 |
|
'endpoint' => ['required', 'string'], |
18
|
1 |
|
'query' => ['nullable', 'string'], |
19
|
1 |
|
]); |
20
|
|
|
|
21
|
1 |
|
$endpoint = $request->input('endpoint'); |
22
|
1 |
|
$query = array_filter(array_map('trim', explode(PHP_EOL, $request->input('query', '')))); |
23
|
1 |
|
$queryData = []; |
24
|
1 |
|
foreach ($query as $line) { |
25
|
1 |
|
$key = Str::before($line, ':'); |
26
|
1 |
|
$value = Str::after($line, ':'); |
27
|
1 |
|
if ($key && $value) { |
28
|
1 |
|
$queryData[$key] = $value; |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** @var PaginatedResponse $response */ |
33
|
1 |
|
$response = NavigaAd::paginatedRequest($endpoint, 2)->setCurrentPage($request->input('page', 1))->retrieve($queryData); |
34
|
|
|
|
35
|
1 |
|
return Response::json([ |
36
|
1 |
|
'data' => $response->entities(), |
37
|
1 |
|
'meta' => [ |
38
|
1 |
|
'currentPage' => $response->currentPage(), |
39
|
1 |
|
'totalPages' => $response->totalPages(), |
40
|
1 |
|
'countEntities' => $response->countEntities(), |
41
|
1 |
|
'totalEntities' => $response->totalEntities(), |
42
|
1 |
|
], |
43
|
1 |
|
]); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths