17 lines
890 B
PHP
17 lines
890 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Enums\AppointmentStatus;
|
|
use App\Services\Tenant\TenantContext;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\View\View;
|
|
|
|
class OwnerReportsController extends Controller
|
|
{
|
|
public function __invoke(TenantContext $tenant): View
|
|
{
|
|
$business = $tenant->require(); $month = Carbon::now($business->timezone)->startOfMonth(); $appointments = $business->appointments()->with('services')->where('startAt', '>=', $month->utc())->get(); $completed = $appointments->where('status', AppointmentStatus::Completed); $revenue = $completed->sum(fn ($appointment) => $appointment->services->sum('priceAtBooking') - (float) ($appointment->discountAmount ?? 0)); $staffCount = $business->staff()->where('status', 'ACTIVE')->count(); return view('owner.reports', compact('business', 'appointments', 'completed', 'revenue', 'staffCount'));
|
|
}
|
|
}
|