$subscribers * @property Collection $episodes * @property int $added_by * @property Carbon $last_synced_at * @property ?string $author */ class Podcast extends Model { use HasFactory; use HasUuids; use Searchable; protected $hidden = ['created_at', 'updated_at']; protected $guarded = []; protected $with = ['subscribers']; protected $casts = [ 'categories' => CategoriesCast::class, 'metadata' => PodcastMetadataCast::class, 'last_synced_at' => 'datetime', 'explicit' => 'boolean', ]; public static function query(): PodcastBuilder { return parent::query(); } public function newEloquentBuilder($query): PodcastBuilder { return new PodcastBuilder($query); } public function episodes(): HasMany { return $this->hasMany(Episode::class)->orderByDesc('created_at'); } public function subscribers(): BelongsToMany { return $this->belongsToMany(User::class) ->using(PodcastUserPivot::class) ->withPivot('state') ->withTimestamps(); } /** @return array */ public function toSearchableArray(): array { return [ 'id' => $this->id, 'url' => $this->url, 'title' => $this->title, 'description' => $this->description, 'author' => $this->metadata->author, ]; } }