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>
85 lines
2.2 KiB
PHP
85 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\BumpsContentVersion;
|
|
use App\Models\Concerns\HasRevisions;
|
|
use Database\Factories\TalkFactory;
|
|
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 Spatie\Translatable\HasTranslations;
|
|
|
|
/**
|
|
* A talk given somewhere that is not this website.
|
|
*
|
|
* The cheapest content there is to keep a site looking alive, and the only
|
|
* kind that shows the collective exists outside its own pages. Written once
|
|
* here, it appears both on the landing page and on the profile of whoever gave
|
|
* it.
|
|
*/
|
|
#[Fillable([
|
|
'title', 'language', 'summary', 'event', 'city', 'held_at',
|
|
'video_url', 'slides_url', 'member_id', 'project_id', 'is_public',
|
|
])]
|
|
class Talk extends Model
|
|
{
|
|
/** @use HasFactory<TalkFactory> */
|
|
use BumpsContentVersion, HasFactory, HasRevisions, HasTranslations;
|
|
|
|
/**
|
|
* The title is the name of that talk, given once in one language.
|
|
* Translating it would invent a talk that never happened — only the
|
|
* summary written about it afterwards is translated.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
public array $translatable = ['summary'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'held_at' => 'date',
|
|
'is_public' => 'boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Member, $this>
|
|
*/
|
|
public function member(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Member::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Project, $this>
|
|
*/
|
|
public function project(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
/**
|
|
* @param Builder<$this> $query
|
|
* @return Builder<$this>
|
|
*/
|
|
public function scopePublic(Builder $query): Builder
|
|
{
|
|
return $query->where('is_public', true);
|
|
}
|
|
|
|
/**
|
|
* @param Builder<$this> $query
|
|
* @return Builder<$this>
|
|
*/
|
|
public function scopeRecentFirst(Builder $query): Builder
|
|
{
|
|
return $query->orderByRaw('held_at is null')->orderByDesc('held_at');
|
|
}
|
|
}
|