Files
core/modules/Profiler/Http/Controllers/RequestController.php
T

37 lines
1.1 KiB
PHP

<?php
namespace Modules\Profiler\Http\Controllers;
use App\Http\Controllers\Admin\Controller;
use Carbon\Carbon;
use Illuminate\Support\Facades\Input;
use Modules\Profiler\Entities\HttpLog;
class RequestController extends Controller
{
public function detail(HttpLog $httpLog)
{
$sameRequests = HttpLog::where('url', $httpLog->url)
->where('method', $httpLog->method);
$pastDays = Input::get('pastDays', session('profilerPastDays', 0));
if (is_numeric($pastDays) && $pastDays >= 0) {
$sameRequests = $sameRequests->where('created_at', '>=', Carbon::today()
->subDays($pastDays));
}
session(['profilerPastDays' => $pastDays]);
$sameRequests = $sameRequests->get();
$times = [
'avg' => $sameRequests->avg('time'),
'min' => $sameRequests->min('time'),
'max' => $sameRequests->max('time')
];
$filter = Input::all();
return view('profiler::request.detail', compact('httpLog', 'sameRequests', 'times', 'pastDays', 'filter'));
}
}