game-village-politics-backend/app/Models/TribeEvent.php

28 lines
724 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use Carbon\CarbonImmutable;
use Illuminate\Database\Eloquent\Model;
/** What happened in a tribe, for its news: joins, leaves, pacts, enmities. */
class TribeEvent extends Model
{
public $timestamps = false;
protected $guarded = [];
protected $dateFormat = 'Y-m-d H:i:s.v';
protected function casts(): array
{
return ['payload' => 'array', 'happened_at' => 'immutable_datetime'];
}
/** @param array<string, mixed> $payload */
public static function note(int $tribeId, string $type, array $payload, CarbonImmutable $at): void
{
self::create(['tribe_id' => $tribeId, 'type' => $type, 'payload' => $payload, 'happened_at' => $at]);
}
}