34 lines
725 B
PHP
34 lines
725 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class VoiceCall extends Model
|
|
{
|
|
protected $fillable = [
|
|
'caller_id', 'callee_id', 'channel_name', 'status', 'answered_at', 'ended_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'answered_at' => 'datetime',
|
|
'ended_at' => 'datetime',
|
|
];
|
|
|
|
public function caller(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'caller_id');
|
|
}
|
|
|
|
public function callee(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'callee_id');
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
return in_array($this->status, ['ringing', 'active']);
|
|
}
|
|
}
|