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>
111 lines
2.8 KiB
PHP
111 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\RadarRing;
|
|
use App\Enums\TechnologyCategory;
|
|
use App\Models\Concerns\BumpsContentVersion;
|
|
use App\Models\Concerns\HasImages;
|
|
use App\Models\Concerns\HasRevisions;
|
|
use Database\Factories\TechnologyFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Spatie\Translatable\HasTranslations;
|
|
|
|
/**
|
|
* A language, framework or tool the collective uses.
|
|
*
|
|
* Shared by projects, members and calls, which is what makes "who knows Rust"
|
|
* and "projects built with Laravel" answerable without duplicating strings.
|
|
*
|
|
* The `name` is deliberately not translatable — technology names are proper
|
|
* nouns. Only the prose about them is.
|
|
*/
|
|
#[Fillable([
|
|
'name', 'slug', 'description', 'radar_note', 'category', 'radar_ring',
|
|
'color', 'icon', 'logo', 'website', 'position',
|
|
])]
|
|
class Technology extends Model
|
|
{
|
|
/** @use HasFactory<TechnologyFactory> */
|
|
use BumpsContentVersion, HasFactory, HasImages, HasRevisions, HasTranslations;
|
|
|
|
/** @var array<int, string> */
|
|
public array $translatable = ['description', 'radar_note'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'category' => TechnologyCategory::class,
|
|
'radar_ring' => RadarRing::class,
|
|
'position' => 'integer',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public function imageAttributes(): array
|
|
{
|
|
return ['logo'];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Media, $this>
|
|
*/
|
|
public function logoMedia(): BelongsTo
|
|
{
|
|
return $this->imageRelation('logo');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<Project, $this>
|
|
*/
|
|
public function projects(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Project::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<Service, $this>
|
|
*/
|
|
public function services(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Service::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<Member, $this>
|
|
*/
|
|
public function members(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Member::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<Call, $this>
|
|
*/
|
|
public function calls(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Call::class);
|
|
}
|
|
|
|
/**
|
|
* Technologies placed on the radar. A technology with no ring is still
|
|
* usable as a tag; it just does not appear in the radar view.
|
|
*
|
|
* @param Builder<$this> $query
|
|
* @return Builder<$this>
|
|
*/
|
|
public function scopeOnRadar(Builder $query): Builder
|
|
{
|
|
return $query->whereNotNull('radar_ring');
|
|
}
|
|
}
|