47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\Maintenance\Http\Controllers\Api\V1;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Modules\Maintenance\Services\MaintenanceDashboardService;
|
|
use Modules\Maintenance\Traits\ResolvesBusiness;
|
|
use Illuminate\Http\Request;
|
|
|
|
class MaintenanceDashboardController extends Controller
|
|
{
|
|
use ResolvesBusiness;
|
|
|
|
public function __construct(
|
|
protected MaintenanceDashboardService $dashboardService
|
|
) {}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$business = $this->resolveBusiness($request);
|
|
if (! $business) {
|
|
return $this->jsonError('کسبوکار یافت نشد.', 404);
|
|
}
|
|
|
|
return $this->jsonSuccess([
|
|
'stats' => $this->dashboardService->getStats($business),
|
|
'recent_activities' => $this->dashboardService->getRecentActivities($business),
|
|
'charts' => $this->dashboardService->getChartData($business),
|
|
]);
|
|
}
|
|
|
|
public function calendar(Request $request)
|
|
{
|
|
$business = $this->resolveBusiness($request);
|
|
if (! $business) {
|
|
return $this->jsonError('کسبوکار یافت نشد.', 404);
|
|
}
|
|
|
|
$start = $request->get('start', now()->startOfMonth()->toDateString());
|
|
$end = $request->get('end', now()->endOfMonth()->toDateString());
|
|
|
|
return $this->jsonSuccess(
|
|
$this->dashboardService->getCalendarEvents($business, $start, $end)
|
|
);
|
|
}
|
|
}
|