mirror of
https://gh.wpcy.net/https://github.com/fairpm/aspirecloud.git
synced 2026-06-19 02:13:44 +08:00
Add a nullable `reported` timestamp column to package_releases for author-declared release dates. Expose both `reported` and `discovered` (mapped from created_at) as ISO 8601 strings in the FAIR metadata response. Includes migration, model cast, factory update, and tests. Closes https://github.com/fairpm/fair-protocol/issues/64 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Joost de Valk <joost@altha.nl>
63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\CarbonImmutable;
|
|
use Database\Factories\PackageReleaseFactory;
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @property-read string $id
|
|
* @property-read string $package_id
|
|
* @property-read string $version
|
|
* @property-read string|null $download_url
|
|
* @property-read array<string, mixed>|null $requires
|
|
* @property-read array<string, mixed>|null $suggests
|
|
* @property-read array<string, mixed>|null $provides
|
|
* @property-read array<string, mixed>|null $artifacts
|
|
* @property-read string|null $signature
|
|
* @property-read string|null $checksum
|
|
* @property-read CarbonImmutable|null $reported
|
|
* @property-read CarbonImmutable|null $created_at
|
|
* @property-read Package|null $package
|
|
*/
|
|
class PackageRelease extends BaseModel
|
|
{
|
|
use HasUuids;
|
|
|
|
/** @use HasFactory<PackageReleaseFactory> */
|
|
use HasFactory;
|
|
|
|
protected $table = 'package_releases';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'id' => 'string',
|
|
'package_id' => 'string',
|
|
'version' => 'string',
|
|
'download_url' => 'string',
|
|
'signature' => 'string',
|
|
'checksum' => 'string',
|
|
'requires' => 'array',
|
|
'suggests' => 'array',
|
|
'provides' => 'array',
|
|
'artifacts' => 'array',
|
|
'reported' => 'immutable_datetime',
|
|
'created_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the package that owns the release.
|
|
*
|
|
* @return BelongsTo<Package, $this>
|
|
*/
|
|
public function package(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Package::class);
|
|
}
|
|
}
|