feat: implement InternshipStatus enum

This commit is contained in:
2025-11-29 14:33:31 +01:00
parent 0ff193fd1e
commit e309d8ea5d
3 changed files with 54 additions and 9 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Enums;
enum InternshipStatus: string
{
case SUBMITTED = 'SUBMITTED';
case CONFIRMED_BY_COMPANY = 'CONFIRMED_BY_COMPANY';
case CONFIRMED_BY_ADMIN = 'CONFIRMED_BY_ADMIN';
case DENIED_BY_COMPANY = 'DENIED_BY_COMPANY';
case DENIED_BY_ADMIN = 'DENIED_BY_ADMIN';
case DEFENDED = 'DEFENDED';
case NOT_DEFENDED = 'NOT_DEFENDED';
public static function all(): array
{
return array_map(fn($case) => $case->value, self::cases());
}
}

View File

@@ -33,6 +33,20 @@ class InternshipStatusData extends Model
'updated_at',
];
protected $table = 'internship_statuses';
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'status' => '\App\Enums\InternshipStatus',
];
}
public function modifiedBy()
{
return $this->belongsTo(User::class, 'modified_by');
@@ -43,7 +57,7 @@ class InternshipStatusData extends Model
return [
'id' => $this->id,
'internship_id' => $this->internship_id,
'status' => $this->status,
'status' => $this->status->value,
'changed' => $this->changed,
'note' => $this->note,
'modified_by' => $this->modifiedBy,