FEATURE #2389 @20m: add deleting all data from profiler
This commit is contained in:
@@ -4,6 +4,7 @@ use App\Http\Controllers\Admin\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Modules\Profiler\Entities\HttpLog;
|
||||
use Modules\Profiler\Entities\QueryLog;
|
||||
|
||||
class ProfilerController extends Controller
|
||||
{
|
||||
@@ -29,6 +30,7 @@ class ProfilerController extends Controller
|
||||
|
||||
if (Input::get('url')) {
|
||||
$httpLog = $httpLog->where('url', Input::get('url'))
|
||||
->orderBy('created_at', 'DESC')
|
||||
->with('queries');
|
||||
} else {
|
||||
$displayGrouped = true;
|
||||
@@ -42,4 +44,24 @@ class ProfilerController extends Controller
|
||||
$filter = Input::all();
|
||||
return view('profiler::index', compact('httpLog', 'displayGrouped', 'filter', 'pastDays'));
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
$older = Input::get('olderThan');
|
||||
|
||||
if (is_null($older)) {
|
||||
\DB::statement("SET foreign_key_checks=0");
|
||||
QueryLog::truncate();
|
||||
HttpLog::truncate();
|
||||
\DB::statement("SET foreign_key_checks=1");
|
||||
} else {
|
||||
HttpLog::where('created_at', '<=', Carbon::now()
|
||||
->subDays($older))
|
||||
->delete();
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('success', trans('profiler::module.succesfullyDeleted'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user