Some checks failed
tests / ci (pull_request) Has been cancelled
- Implemented StudentService to retrieve all students for selection. - Created migration for tuition_invoices and tuition_payments tables. - Added seeders for TuitionInvoice and TuitionPayment with sample data. - Updated DatabaseSeeder to include new seeders. - Developed UI components for managing tuition invoices and payments, including forms and data tables. - Introduced RupiahInput component for formatted currency input. - Added routes for tuition invoices and payments management. - Defined TypeScript types for tuition invoices and payments.
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\Semester;
|
|
use Illuminate\Database\Eloquent\Attributes\Appends;
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
#[Guarded(['id'])]
|
|
#[Appends(['formatted_start_date', 'formatted_end_date'])]
|
|
class AcademicTerm extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public function tuitionInvoices(): HasMany
|
|
{
|
|
return $this->hasMany(TuitionInvoice::class);
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'semester' => Semester::class,
|
|
'start_date' => 'date',
|
|
'end_date' => 'date',
|
|
'is_active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
protected function formattedStartDate(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => $this->start_date->format('d M Y'),
|
|
);
|
|
}
|
|
|
|
protected function formattedEndDate(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => $this->end_date->format('d M Y'),
|
|
);
|
|
}
|
|
}
|