<?php

namespace App\Http\Controllers;

use App\Models\Meeting;
use App\Models\MeetingParticipant;
use Illuminate\Http\Request;
use App\Models\Pro;
use App\Models\AppSession;
use App\HttpModels\ProModel;
use App\HttpModels\MeetingWithLobbyModel;

class MeetingCenterController extends Controller
{

    public function mc(Request $request, $fragment) {
        $page = "/my_teams";
        if($fragment) {
            $page = '/' . $fragment;
        }

        $sessionKey = $request->cookie("sessionKey");

        $appSession = AppSession::where("session_key",$sessionKey)->first();
        $user = new ProModel($appSession->pro);
        $user->sessionKey = $sessionKey;
        $meeting = null;
        if ($appSession->is_currently_meeting_participant && $appSession->meetingParticipant->meeting->is_active) {
            $meeting = new MeetingWithLobbyModel($appSession->meetingParticipant->meeting);
        }

        return view('mc', compact('page','user','meeting'));
    }

}