<?php

namespace App\Http\Controllers;

use App\Models\Meeting;
use App\Models\MeetingParticipant;
use Illuminate\Http\Request;
use App\Models\Pro;

class GuestController extends Controller
{

    public function meeting(Request $request, $meetingID, $participantID) {
        $meeting = Meeting::where('uid', $meetingID)->first();
        if(!$meeting) {
            return abort(404, "Meeting no longer active");
        }
        $participants = MeetingParticipant::where('meeting_id', $meeting->id)->get();
        foreach ($participants as $participant) {
            $participant->proName = $participant->proName(); // eager-fill proName
        }
        return view('meeting', [
            'meetingID' => $meetingID,
            'participantID'=> $participantID,
            'participants' => $participants,
            'guest' => true
        ]);
    }

}
