Phases 0–18: core meetings, webinar, breakouts, team chat, live streaming, town hall, billing, and Ladill Mail calendar wiring. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Room extends Model
|
||||
{
|
||||
use BelongsToOwner, SoftDeletes;
|
||||
|
||||
protected $table = 'meet_rooms';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid', 'owner_ref', 'organization_id', 'branch_id', 'host_user_ref',
|
||||
'title', 'description', 'type', 'status', 'slug', 'scheduled_at',
|
||||
'duration_minutes', 'timezone', 'passcode', 'settings', 'source', 'calendar_event_id',
|
||||
'template_id', 'recurring_series_id', 'recurrence_rule', 'recurrence_interval', 'recurrence_until',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'scheduled_at' => 'datetime',
|
||||
'recurrence_until' => 'date',
|
||||
'settings' => 'array',
|
||||
'source' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Room $room) {
|
||||
if (empty($room->uuid)) {
|
||||
$room->uuid = (string) Str::uuid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'uuid';
|
||||
}
|
||||
|
||||
public function organization(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id');
|
||||
}
|
||||
|
||||
public function sessions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Session::class, 'room_id');
|
||||
}
|
||||
|
||||
public function invitations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invitation::class, 'room_id');
|
||||
}
|
||||
|
||||
public function webinarRegistrations(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebinarRegistration::class, 'room_id');
|
||||
}
|
||||
|
||||
public function sessionFiles(): HasMany
|
||||
{
|
||||
return $this->hasMany(SessionFile::class, 'room_id');
|
||||
}
|
||||
|
||||
public function isWebinar(): bool
|
||||
{
|
||||
return $this->type === 'webinar';
|
||||
}
|
||||
|
||||
public function isTownHall(): bool
|
||||
{
|
||||
return $this->type === 'town_hall';
|
||||
}
|
||||
|
||||
public function template(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Template::class, 'template_id');
|
||||
}
|
||||
|
||||
public function isRecurring(): bool
|
||||
{
|
||||
return filled($this->recurrence_rule);
|
||||
}
|
||||
|
||||
public function activeSession(): ?Session
|
||||
{
|
||||
return $this->sessions()->where('status', 'live')->latest()->first();
|
||||
}
|
||||
|
||||
public function setting(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return data_get($this->settings, $key, data_get(config('meet.default_settings'), $key, $default));
|
||||
}
|
||||
|
||||
public function isLive(): bool
|
||||
{
|
||||
return $this->status === 'live';
|
||||
}
|
||||
|
||||
public function joinUrl(): string
|
||||
{
|
||||
return url('/r/'.$this->uuid);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user