2018-12-03 21:59:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
2025-01-16 07:54:02 +00:00
|
|
|
namespace BlaxSoftware\LaravelWebSockets\Dashboard\Http\Controllers;
|
2018-12-03 21:59:50 +00:00
|
|
|
|
2025-01-16 07:54:02 +00:00
|
|
|
use BlaxSoftware\LaravelWebSockets\Facades\StatisticsStore;
|
2020-08-20 08:27:55 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
2020-08-23 17:41:17 +00:00
|
|
|
class ShowStatistics
|
2018-12-03 21:59:50 +00:00
|
|
|
{
|
2020-08-18 17:21:22 +00:00
|
|
|
/**
|
|
|
|
|
* Get statistics for an app ID.
|
|
|
|
|
*
|
2020-08-20 08:27:55 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2020-08-18 17:21:22 +00:00
|
|
|
* @param mixed $appId
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
2020-09-10 19:59:26 +00:00
|
|
|
public function __invoke(Request $request, $appId)
|
2018-12-03 21:59:50 +00:00
|
|
|
{
|
2020-09-10 19:59:26 +00:00
|
|
|
$processQuery = function ($query) use ($appId) {
|
|
|
|
|
return $query->whereAppId($appId)
|
|
|
|
|
->latest()
|
|
|
|
|
->limit(120);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$processCollection = function ($collection) {
|
|
|
|
|
return $collection->reverse();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return StatisticsStore::getForGraph(
|
|
|
|
|
$processQuery, $processCollection
|
|
|
|
|
);
|
2018-12-03 21:59:50 +00:00
|
|
|
}
|
2018-12-04 21:22:33 +00:00
|
|
|
}
|