41 lines
748 B
PHP
41 lines
748 B
PHP
<?php
|
|
|
|
namespace App\Models\Chat;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Message extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'conversation_id',
|
|
'user_id',
|
|
'body',
|
|
'seen_at',
|
|
];
|
|
|
|
/**
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'seen_at' => 'datetime',
|
|
];
|
|
|
|
public function conversation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Conversation::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|