Action::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 17
rs 10
1
<?php
2
3
/*
4
 * This file is part of Laravel Sense.
5
 *
6
 * (c) Anton Komarev <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cog\Laravel\Sense\Http\Controllers\Queries\Collect;
15
16
use Cog\Laravel\Sense\Db\Query\Models\Query;
17
use Cog\Laravel\Sense\Http\Controllers\Controller;
18
19
class Action extends Controller
20
{
21
    public function __invoke(Request $request)
22
    {
23
        $query = Query::query();
24
25
        if ($requestId = $request->input('filter.request.id')) {
26
            $query->where('request_id', $requestId);
27
        }
28
        if ($statementId = $request->input('filter.statement.id')) {
29
            $query->where('statement_id', $statementId);
30
        }
31
32
        $query->with([
33
        ]);
34
35
        $queries = $query->latest('id')->get();
36
37
        return new Response($queries);
38
    }
39
}
40