Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* An open issue mirrored from a repository.
|
|
*
|
|
* Only issues worth showing a newcomer are kept — the ones labelled as good
|
|
* first issues or help wanted. Mirroring every open issue would be noise.
|
|
*/
|
|
#[Fillable([
|
|
'repository_id', 'number', 'title', 'html_url', 'labels',
|
|
'is_good_first_issue', 'is_help_wanted', 'author', 'assignee',
|
|
'comments', 'issue_created_at', 'issue_updated_at',
|
|
])]
|
|
class RepositoryIssue extends Model
|
|
{
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'labels' => 'array',
|
|
'is_good_first_issue' => 'boolean',
|
|
'is_help_wanted' => 'boolean',
|
|
'comments' => 'integer',
|
|
'issue_created_at' => 'datetime',
|
|
'issue_updated_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Repository, $this>
|
|
*/
|
|
public function repository(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Repository::class);
|
|
}
|
|
|
|
/**
|
|
* Nobody has picked it up yet, so it is genuinely available.
|
|
*/
|
|
public function isUnclaimed(): bool
|
|
{
|
|
return blank($this->assignee);
|
|
}
|
|
|
|
/**
|
|
* @param Builder<$this> $query
|
|
* @return Builder<$this>
|
|
*/
|
|
public function scopeAvailable(Builder $query): Builder
|
|
{
|
|
return $query->whereNull('assignee');
|
|
}
|
|
}
|