<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Spatie\Permission\Models\Role;
use Veelasky\LaravelHashId\Eloquent\HashableId;

class Broadcast extends Model
{
    use HasFactory, HashableId;

    protected $guarded = ['id'];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function audiences(): BelongsToMany
    {
        return $this->belongsToMany(Role::class, 'broadcast_audiences', 'broadcast_id', 'audience_id');
    }
}
