FEATURE #2389 @20m: add deleting all data from profiler

This commit is contained in:
Michal Kváček
2017-03-28 01:01:21 +02:00
parent aa55ffe46a
commit 7d6a3737e3
9 changed files with 156 additions and 85 deletions
@@ -1,7 +1,10 @@
<?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
@@ -9,8 +12,17 @@ class RequestController extends Controller
public function detail(HttpLog $httpLog)
{
$sameRequests = HttpLog::where('url', $httpLog->url)
->where('method', $httpLog->method)
->get();
->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'),
@@ -18,6 +30,8 @@ class RequestController extends Controller
'max' => $sameRequests->max('time')
];
return view('profiler::request.detail', compact('httpLog', 'sameRequests', 'times'));
$filter = Input::all();
return view('profiler::request.detail', compact('httpLog', 'sameRequests', 'times', 'pastDays', 'filter'));
}
}