96 lines
2.1 KiB
PHP
96 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ClientMeeting extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'client_id',
|
|
'title',
|
|
'agenda',
|
|
'meeting_code',
|
|
'meeting_type',
|
|
'scheduled_at',
|
|
'duration_minutes',
|
|
'host_user_id',
|
|
'team_attendees',
|
|
'client_emails',
|
|
'status',
|
|
'started_at',
|
|
'ended_at',
|
|
'active_peers',
|
|
'peer_signals',
|
|
'chat_messages',
|
|
'recording_path',
|
|
'recordings',
|
|
];
|
|
|
|
protected $casts = [
|
|
'scheduled_at' => 'datetime',
|
|
'started_at' => 'datetime',
|
|
'ended_at' => 'datetime',
|
|
'team_attendees' => 'array',
|
|
'client_emails' => 'array',
|
|
'active_peers' => 'array',
|
|
'peer_signals' => 'array',
|
|
'chat_messages' => 'array',
|
|
'recordings' => 'array',
|
|
];
|
|
|
|
/**
|
|
* The parent client profile.
|
|
*/
|
|
public function client()
|
|
{
|
|
return $this->belongsTo(Client::class, 'client_id');
|
|
}
|
|
|
|
/**
|
|
* Host user who organized the call.
|
|
*/
|
|
public function host()
|
|
{
|
|
return $this->belongsTo(User::class, 'host_user_id');
|
|
}
|
|
|
|
/**
|
|
* Notes and MoM entries for this meeting.
|
|
*/
|
|
public function callNotes()
|
|
{
|
|
return $this->hasMany(ClientCallNote::class, 'client_meeting_id')->orderBy('created_at', 'desc');
|
|
}
|
|
|
|
/**
|
|
* Latest call note or MoM.
|
|
*/
|
|
public function latestNote()
|
|
{
|
|
return $this->hasOne(ClientCallNote::class, 'client_meeting_id')->latestOfMany();
|
|
}
|
|
|
|
/**
|
|
* Get assigned team attendees User models.
|
|
*/
|
|
public function getTeamAttendees()
|
|
{
|
|
if (empty($this->team_attendees)) {
|
|
return collect();
|
|
}
|
|
return User::whereIn('id', $this->team_attendees)->get();
|
|
}
|
|
|
|
/**
|
|
* Helper to get shareable join URL.
|
|
*/
|
|
public function getJoinUrlAttribute(): string
|
|
{
|
|
return route('client-calls.room', ['code' => $this->meeting_code]);
|
|
}
|
|
}
|