update api and add more features

This commit is contained in:
root
2026-06-04 02:24:41 -04:00
parent fa6c9519a0
commit 4e33882ac7
131 changed files with 34596 additions and 340 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests\Finance;
use App\Http\Requests\ApiFormRequest;
class ApplyExtraChargeRequest extends ApiFormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'invoice_id' => ['required', 'integer', 'min:1'],
];
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Finance;
use App\Http\Requests\ApiFormRequest;
class ChargeListRequest extends ApiFormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'parent_id' => ['required', 'integer', 'min:1'],
'school_year' => ['nullable', 'string', 'max:20'],
];
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Finance;
use App\Http\Requests\ApiFormRequest;
class FeeFamilyBalanceRequest extends ApiFormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'parent_id' => ['required', 'integer', 'min:1'],
'school_year' => ['nullable', 'string', 'max:20'],
'students' => ['required', 'array', 'min:1'],
'students.*.student_id' => ['nullable', 'integer', 'min:1'],
'students.*.firstname' => ['nullable', 'string', 'max:100'],
'students.*.lastname' => ['nullable', 'string', 'max:100'],
'students.*.class_section_id' => ['nullable', 'integer', 'min:1'],
'students.*.grade' => ['nullable', 'string', 'max:20'],
'students.*.enrollment_status' => ['nullable', 'string', 'max:50'],
'students.*.admission_status' => ['nullable', 'string', 'max:50'],
'students.*.discount_amount' => ['nullable', 'numeric', 'min:0'],
];
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests\Finance;
use App\Http\Requests\ApiFormRequest;
class FeeTuitionBreakdownRequest extends ApiFormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'students' => ['required', 'array', 'min:1'],
'students.*.student_id' => ['nullable', 'integer', 'min:1'],
'students.*.firstname' => ['nullable', 'string', 'max:100'],
'students.*.lastname' => ['nullable', 'string', 'max:100'],
'students.*.class_section_id' => ['nullable', 'integer', 'min:1'],
'students.*.grade' => ['nullable', 'string', 'max:20'],
'students.*.enrollment_status' => ['nullable', 'string', 'max:50'],
'students.*.admission_status' => ['nullable', 'string', 'max:50'],
'students.*.discount_amount' => ['nullable', 'numeric', 'min:0'],
];
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Finance;
use App\Http\Requests\ApiFormRequest;
class MarkEventChargePaidRequest extends ApiFormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'paid' => ['required', 'boolean'],
'payment_id' => ['nullable', 'integer', 'min:1'],
];
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Requests\Finance;
use App\Http\Requests\ApiFormRequest;
class StoreEventChargeRequest extends ApiFormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'parent_id' => ['required', 'integer', 'min:1'],
'student_id' => ['required', 'integer', 'min:1'],
'event_id' => ['nullable', 'integer', 'min:1'],
'event_name' => ['required_without:event_id', 'nullable', 'string', 'max:255'],
'amount' => ['nullable', 'numeric', 'min:0'],
'description' => ['nullable', 'string', 'max:2000'],
'school_year' => ['nullable', 'string', 'max:20'],
'semester' => ['nullable', 'string', 'max:20'],
];
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests\Finance;
use App\Http\Requests\ApiFormRequest;
class StoreExtraChargeRequest extends ApiFormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
public function rules(): array
{
return [
'parent_id' => ['required', 'integer', 'min:1'],
'title' => ['required', 'string', 'min:2', 'max:255'],
'amount' => ['required', 'numeric', 'min:0.01'],
'charge_type' => ['required', 'in:add,deduct'],
'description' => ['nullable', 'string', 'max:2000'],
'due_date' => ['nullable', 'date_format:Y-m-d'],
'invoice_id' => ['nullable', 'integer', 'min:1'],
'school_year' => ['nullable', 'string', 'max:20'],
'semester' => ['nullable', 'string', 'max:20'],
];
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
use App\Models\StudentPromotionRecord;
use Illuminate\Validation\Rule;
class AdminListPromotionsRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'status' => ['nullable'],
'status.*' => ['string', Rule::in(StudentPromotionRecord::ALL_STATUSES)],
'next_school_year' => ['nullable', 'string', 'max:9'],
'current_school_year' => ['nullable', 'string', 'max:9'],
'parent_id' => ['nullable', 'integer', 'min:1'],
'student_id' => ['nullable', 'integer', 'min:1'],
'search' => ['nullable', 'string', 'max:191'],
'parent_action_required' => ['nullable', 'boolean'],
'page' => ['nullable', 'integer', 'min:1'],
'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
];
}
public function filters(): array
{
$data = $this->validated();
$status = $data['status'] ?? null;
if (is_string($status) && $status !== '') {
$status = [$status];
} elseif (!is_array($status)) {
$status = null;
}
return [
'status' => $status,
'next_school_year' => $data['next_school_year'] ?? null,
'current_school_year' => $data['current_school_year'] ?? null,
'parent_id' => isset($data['parent_id']) ? (int) $data['parent_id'] : null,
'student_id' => isset($data['student_id']) ? (int) $data['student_id'] : null,
'search' => $data['search'] ?? null,
'parent_action_required' => isset($data['parent_action_required'])
? (bool) $data['parent_action_required']
: false,
'page' => isset($data['page']) ? (int) $data['page'] : 1,
'per_page' => isset($data['per_page']) ? (int) $data['per_page'] : 50,
];
}
}
@@ -0,0 +1,18 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
class EvaluateEligibilityRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'scope' => ['nullable', 'string', 'in:student,class_section,school_year'],
'student_id' => ['nullable', 'integer', 'min:1', 'required_if:scope,student'],
'class_section_id' => ['nullable', 'integer', 'min:1', 'required_if:scope,class_section'],
'current_school_year' => ['nullable', 'string', 'max:9'],
];
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
class ParentEnrollmentStepRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'info_confirmed' => ['nullable', 'boolean'],
'documents_uploaded' => ['nullable', 'boolean'],
'agreement_accepted' => ['nullable', 'boolean'],
'payment_completed' => ['nullable', 'boolean'],
];
}
public function steps(): array
{
$data = $this->validated();
$steps = [];
foreach (['info_confirmed', 'documents_uploaded', 'agreement_accepted', 'payment_completed'] as $field) {
if (array_key_exists($field, $data) && $data[$field] !== null) {
$steps[$field] = (bool) $data[$field];
}
}
return $steps;
}
}
@@ -0,0 +1,15 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
class ParentPromotionOverviewRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'next_school_year' => ['nullable', 'string', 'max:9'],
];
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
use App\Models\PromotionReminderLog;
use Illuminate\Validation\Rule;
class SendReminderRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'reminder_type' => ['nullable', 'string', Rule::in(PromotionReminderLog::ALLOWED_TYPES)],
'subject' => ['nullable', 'string', 'max:191'],
'message' => ['nullable', 'string', 'max:5000'],
'channels' => ['nullable', 'array'],
'channels.*' => ['string', Rule::in(['in_app', 'email', 'sms'])],
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
class SetEnrollmentDeadlineRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'enrollment_deadline' => ['required', 'date_format:Y-m-d'],
'apply_to' => ['nullable', 'string', 'in:single,school_year,filter'],
'next_school_year' => ['nullable', 'string', 'max:9'],
'promotion_ids' => ['nullable', 'array'],
'promotion_ids.*' => ['integer', 'min:1'],
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
use App\Models\StudentPromotionRecord;
use Illuminate\Validation\Rule;
class UpdatePromotionStatusRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'status' => ['required', 'string', Rule::in(StudentPromotionRecord::ALL_STATUSES)],
'force' => ['nullable', 'boolean'],
'notes' => ['nullable', 'string', 'max:500'],
];
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests\Promotions;
use App\Http\Requests\ApiFormRequest;
class UpsertLevelProgressionRequest extends ApiFormRequest
{
public function rules(): array
{
return [
'current_level_id' => ['nullable', 'integer', 'min:1'],
'current_level_name' => ['required', 'string', 'max:100'],
'next_level_id' => ['nullable', 'integer', 'min:1'],
'next_level_name' => ['nullable', 'string', 'max:100'],
'order_index' => ['nullable', 'integer', 'min:0', 'max:65535'],
'is_terminal' => ['nullable', 'boolean'],
'is_active' => ['nullable', 'boolean'],
'notes' => ['nullable', 'string', 'max:500'],
];
}
}