Files
landing-api/app/Models/ReviewComment.php
Josep Piguillem 3897113313 Initial commit: Pireon Admin — headless admin panel and public API
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>
2026-08-19 17:55:27 +02:00

58 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use App\Enums\ReviewEvent;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
/**
* One thing somebody said while a record was being reviewed.
*
* Sits beside the change history rather than inside it. A revision knows the
* title used to be something else; it cannot know that the reason this went
* back is that the photo is missing, because nobody typed that anywhere the
* history could see.
*/
#[Fillable(['user_id', 'user_name', 'event', 'body'])]
class ReviewComment extends Model
{
protected function casts(): array
{
return ['event' => ReviewEvent::class];
}
/**
* @return MorphTo<Model, $this>
*/
public function reviewable(): MorphTo
{
return $this->morphTo();
}
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* The live name when the account is at hand — people rename themselves —
* and the recorded one otherwise, including once the account is gone.
*/
public function author(): string
{
if ($this->relationLoaded('user') && $this->user !== null) {
return $this->user->name;
}
return $this->user_name ?? __('panel.revisions.system');
}
}