mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Server\Http\Controllers\Admin;
|
|
|
|
use App\Contracts\StatisticsRepository;
|
|
use Illuminate\Http\Request;
|
|
use Ratchet\ConnectionInterface;
|
|
|
|
class GetStatisticsController extends AdminController
|
|
{
|
|
protected $keepConnectionOpen = true;
|
|
|
|
/** @var StatisticsRepository */
|
|
protected $statisticsRepository;
|
|
|
|
public function __construct(StatisticsRepository $statisticsRepository)
|
|
{
|
|
$this->statisticsRepository = $statisticsRepository;
|
|
}
|
|
|
|
public function handle(Request $request, ConnectionInterface $httpConnection)
|
|
{
|
|
$from = today()->subWeek()->toDateString();
|
|
$until = today()->toDateString();
|
|
|
|
$this->statisticsRepository->getStatistics($request->get('from', $from), $request->get('until', $until))
|
|
->then(function ($statistics) use ($httpConnection) {
|
|
$httpConnection->send(
|
|
respond_json([
|
|
'statistics' => $statistics,
|
|
])
|
|
);
|
|
|
|
$httpConnection->close();
|
|
});
|
|
}
|
|
}
|