Initial Commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class DirectThread extends Model
|
||||
{
|
||||
protected $table = 'dm_threads';
|
||||
protected $primaryKey = 'thread_id';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'thread_id', 'thread_key', 'thread_title', 'is_group',
|
||||
'participants', 'last_activity_at', 'muted',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'participants' => 'array',
|
||||
'is_group' => 'boolean',
|
||||
'muted' => 'boolean',
|
||||
'last_activity_at' => 'integer',
|
||||
'scraped_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function messages(): HasMany
|
||||
{
|
||||
return $this->hasMany(DirectMessage::class, 'thread_id', 'thread_id');
|
||||
}
|
||||
|
||||
public function getLastActivityAtDateAttribute(): ?\Carbon\Carbon
|
||||
{
|
||||
return $this->last_activity_at
|
||||
? \Carbon\Carbon::createFromTimestampMs($this->last_activity_at)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user