Some checks failed
tests / ci (pull_request) Has been cancelled
- Added Semester enum with labels for odd and even semesters. - Created AcademicTerm model, controller, service, and request for handling academic terms. - Implemented paginated listing, creation, updating, and deletion of academic terms. - Added routes for academic terms management under admin/master. - Created frontend components for displaying and managing academic terms, including forms and data tables. - Integrated confirmation dialog for delete actions and form dialogs for creating and editing academic terms. - Added seeder for initial academic term data.
42 lines
1013 B
PHP
42 lines
1013 B
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;
|
|
|
|
#[Guarded(['id'])]
|
|
#[Appends(['formatted_start_date', 'formatted_end_date'])]
|
|
class AcademicTerm extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
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'),
|
|
);
|
|
}
|
|
}
|