Initial Commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?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', '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',
|
||||
'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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user