socialblue /
laravel-query-adviser
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Socialblue\LaravelQueryAdviser\Http\Controllers; |
||||
| 4 | |||||
| 5 | use Illuminate\Http\Request; |
||||
| 6 | use Illuminate\Routing\Controller; |
||||
| 7 | use Illuminate\Support\Facades\Cache; |
||||
| 8 | use Illuminate\Support\Facades\DB; |
||||
| 9 | use Socialblue\LaravelQueryAdviser\DataListener\Services\BindingsMapper; |
||||
| 10 | use Socialblue\LaravelQueryAdviser\Helper\QueryBuilderHelper; |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * Class QueryController |
||||
| 14 | * @package Socialblue\LaravelQueryAdviser\Http\Controllers |
||||
| 15 | */ |
||||
| 16 | class QueryController extends Controller |
||||
| 17 | { |
||||
| 18 | /** |
||||
| 19 | * Execute query |
||||
| 20 | */ |
||||
| 21 | public function exec(string $sessionKey, string $time, string $timeKey, Request $request): array |
||||
|
0 ignored issues
–
show
|
|||||
| 22 | { |
||||
| 23 | $data = Cache::get($sessionKey); |
||||
| 24 | |||||
| 25 | if (isset($data[$time][$timeKey])) { |
||||
| 26 | $query = $data[$time][$timeKey]; |
||||
| 27 | return DB::connection()->select($query['rawSql'], (new BindingsMapper())->fromCache($query['bindings'])); |
||||
| 28 | } |
||||
| 29 | |||||
| 30 | return []; |
||||
| 31 | } |
||||
| 32 | |||||
| 33 | /** |
||||
| 34 | * Use explain for query |
||||
| 35 | */ |
||||
| 36 | public function explain(string $sessionKey, string $time, string $timeKey, Request $request): array |
||||
|
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 37 | { |
||||
| 38 | $data = Cache::get($sessionKey); |
||||
| 39 | if (isset($data[$time][$timeKey])) { |
||||
| 40 | $query = $data[$time][$timeKey]; |
||||
| 41 | return QueryBuilderHelper::analyze($query['rawSql'], (new BindingsMapper())->fromCache($query['bindings'])); |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | return [ |
||||
| 45 | 'queryParts' => "", |
||||
| 46 | 'query' => "", |
||||
| 47 | 'optimized' => "", |
||||
| 48 | ]; |
||||
| 49 | } |
||||
| 50 | } |
||||
| 51 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.