@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ProjectProgram;
|
||||
use App\Enums\ProjectSector;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* An entry in PAJ's IT project track record (the site's portfolio).
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string $client
|
||||
* @property int $year
|
||||
* @property ProjectSector $sector
|
||||
* @property ProjectProgram|null $program
|
||||
* @property string|null $scope
|
||||
*/
|
||||
#[Fillable(['title', 'client', 'year', 'sector', 'program', 'scope'])]
|
||||
class Project extends Model
|
||||
{
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'year' => 'integer',
|
||||
'sector' => ProjectSector::class,
|
||||
'program' => ProjectProgram::class,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Newest projects first, as the site lists them.
|
||||
*
|
||||
* @param Builder<Project> $query
|
||||
*/
|
||||
public function scopeLatestFirst(Builder $query): void
|
||||
{
|
||||
$query->orderByDesc('year')->orderBy('id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user