<?php
namespace App\HttpModels;

use App\Models\Lobby;
use Carbon\Carbon;

class LobbyModel extends ClientLobbyModel {
    public $isStrangerAccessible;
    public $isClientAccessible;
    public $isActive;
    public $lobbyProAccessLevel;
    public $meetings = [];

    public function __construct(Lobby $lobby)
    {
        parent::__construct($lobby);
        $this->isStrangerAccessible = $lobby->is_stranger_accessible;
        $this->isClientAccessible = $lobby->is_client_accessible;
        $this->isActive = $lobby->is_active;
        $this->lobbyProAccessLevel = $lobby->lobby_pro_access_level;
        foreach ($lobby->meetings()->where('meeting.is_active',true)->where('created_at','>=',Carbon::today())->get() as $meeting) {
            $this->meetings[] = new MeetingModel($meeting);
        }
    }
}