add test batches

This commit is contained in:
root
2026-06-08 23:45:55 -04:00
parent c792b8be05
commit 8d4d610b82
1480 changed files with 22587 additions and 10762 deletions
@@ -4,6 +4,7 @@ namespace App\Services\Events;
use App\Models\EventCharges;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\DB;
class EventChargeQueryService
{
@@ -25,16 +26,16 @@ class EventChargeQueryService
->leftJoin('students', 'students.id', '=', 'event_charges.student_id')
->leftJoin('events', 'events.id', '=', 'event_charges.event_id');
if (! empty($filters['school_year'])) {
if (!empty($filters['school_year'])) {
$query->where('event_charges.school_year', (string) $filters['school_year']);
}
if (! empty($filters['semester'])) {
if (!empty($filters['semester'])) {
$query->where('event_charges.semester', (string) $filters['semester']);
}
if (! empty($filters['parent_id'])) {
if (!empty($filters['parent_id'])) {
$query->where('event_charges.parent_id', (int) $filters['parent_id']);
}
if (! empty($filters['event_id'])) {
if (!empty($filters['event_id'])) {
$query->where('event_charges.event_id', (int) $filters['event_id']);
}
+4 -3
View File
@@ -9,7 +9,9 @@ use App\Services\Invoices\InvoiceGenerationService;
class EventChargeService
{
public function __construct(private InvoiceGenerationService $invoiceGeneration) {}
public function __construct(private InvoiceGenerationService $invoiceGeneration)
{
}
public function seedChargesForEvent(Event $event, string $schoolYear, string $semester, float $amount, int $actorId): array
{
@@ -80,7 +82,7 @@ class EventChargeService
int $actorId
): array {
$event = Event::getEvent($eventId, $schoolYear);
if (! $event) {
if (!$event) {
return ['ok' => false, 'message' => 'Event not found.'];
}
@@ -107,7 +109,6 @@ class EventChargeService
$existing->delete();
$deleted++;
}
continue;
}
+6 -6
View File
@@ -16,19 +16,19 @@ class EventListService
$activeOnly = $filters['active'] ?? null;
$allowedSorts = ['created_at', 'expiration_date', 'event_name'];
if (! in_array($sortBy, $allowedSorts, true)) {
if (!in_array($sortBy, $allowedSorts, true)) {
$sortBy = 'created_at';
}
$query = Event::query();
if (! empty($filters['school_year'])) {
if (!empty($filters['school_year'])) {
$query->where('school_year', (string) $filters['school_year']);
}
if (! empty($filters['semester'])) {
if (!empty($filters['semester'])) {
$query->where('semester', (string) $filters['semester']);
}
if (! empty($filters['q'])) {
if (!empty($filters['q'])) {
$term = trim((string) $filters['q']);
$query->where('event_name', 'like', "%{$term}%");
}
@@ -67,10 +67,10 @@ class EventListService
private function activeCount(array $filters): int
{
$query = Event::query()->whereDate('expiration_date', '>=', now()->toDateString());
if (! empty($filters['school_year'])) {
if (!empty($filters['school_year'])) {
$query->where('school_year', (string) $filters['school_year']);
}
if (! empty($filters['semester'])) {
if (!empty($filters['semester'])) {
$query->where('semester', (string) $filters['semester']);
}
@@ -13,7 +13,8 @@ class EventManagementService
public function __construct(
private EventChargeService $charges,
private InvoiceGenerationService $invoiceGeneration
) {}
) {
}
public function create(array $payload, ?UploadedFile $flyer, int $actorId): array
{
@@ -53,7 +54,7 @@ class EventManagementService
public function update(int $eventId, array $payload, ?UploadedFile $flyer): array
{
$event = Event::query()->find($eventId);
if (! $event) {
if (!$event) {
return ['ok' => false, 'message' => 'Event not found.'];
}
@@ -80,7 +81,7 @@ class EventManagementService
public function delete(int $eventId, int $actorId): array
{
$event = Event::query()->find($eventId);
if (! $event) {
if (!$event) {
return ['ok' => false, 'message' => 'Event not found.'];
}
@@ -98,7 +99,7 @@ class EventManagementService
private function storeFlyer(?UploadedFile $file): ?string
{
if (! $file || ! $file->isValid()) {
if (!$file || !$file->isValid()) {
return null;
}
@@ -119,13 +120,13 @@ class EventManagementService
}
$dir = public_path('uploads/event_flyers');
if (! File::exists($dir)) {
if (!File::exists($dir)) {
File::makeDirectory($dir, 0755, true);
}
$name = bin2hex(random_bytes(16)).'.'.$allowed[$mime];
$name = bin2hex(random_bytes(16)) . '.' . $allowed[$mime];
$file->move($dir, $name);
return 'event_flyers/'.$name;
return 'event_flyers/' . $name;
}
}
@@ -30,7 +30,7 @@ class EventStudentChargeService
foreach ($students as $student) {
$data[] = [
'id' => (int) ($student['id'] ?? 0),
'name' => trim(($student['firstname'] ?? '').' '.($student['lastname'] ?? '')),
'name' => trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? '')),
'charged' => isset($chargedMap[(int) ($student['id'] ?? 0)]),
];
}