Files
dredgegram/app/Models/DirectMessage.php
dredgy 37ff8e0a88
linter / quality (push) Canceled after 0s
tests / ci (8.3) (push) Canceled after 0s
tests / ci (8.4) (push) Canceled after 0s
tests / ci (8.5) (push) Canceled after 0s
Initial Commit
2026-08-28 23:53:45 +10:00

47 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class DirectMessage extends Model
{
protected $table = 'dm_messages';
protected $primaryKey = 'id';
public $incrementing = false;
protected $keyType = 'string';
public $timestamps = false;
protected $fillable = [
'id', 'thread_id', 'user_id', 'username', 'full_name', 'item_type', 'text',
'media_url', 'is_video', 'attachments', 'timestamp', 'shared_url', 'shared_preview_image',
'shared_title', 'shared_caption', 'reactions', 'replied_to_id', 'replied_to_text',
];
protected $casts = [
'is_video' => 'boolean',
'timestamp' => 'integer',
'reactions' => 'array',
'attachments' => 'array',
'scraped_at' => 'datetime',
];
public function thread(): BelongsTo
{
return $this->belongsTo(DirectThread::class, 'thread_id', 'thread_id');
}
public function repliedTo(): BelongsTo
{
return $this->belongsTo(self::class, 'replied_to_id', 'id');
}
public function getSentAtAttribute(): ?\Carbon\Carbon
{
return $this->timestamp
? \Carbon\Carbon::createFromTimestampMs($this->timestamp)
: null;
}
}