/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $room = Room::findOrFail($id); if (!roomController::checkOwner($room)) { throw new Exception('Unauthorized'); } //get all servers meeting existed and destroy $bbb_servers = $room->meetings()->groupBy('bbb_server')->get(['bbb_server']); $recordings = array(); //end meeting in bbb if running $bbb_id = bbbController::running($room); if ($bbb_id) { $bbb = new BigBlueButton($bbb_id); if ($bbb->isUp()) { $endParams = array('meetingId' => $room->bbb_meeting_id, 'password' => $room->mod_pass); $bbb->endMeetingWithXmlResponseArray($endParams); } } //delete recordings $recordings = recordingsController::get($room); if ($recordings) { //keep recordings from each server foreach ($recordings as $rec) { $rids[$rec->server_id] = $rec['recordId'] . ','; } //send requests to servers foreach ($rids as $server_id => $recordind_ids) { $bbb = new BigBlueButton($server_id); if ($bbb->isUp()) { $bbb->deleteRecordingsWithXmlResponseArray(array('recordId' => $recording_ids)); } } } //delete room from database $room->delete(); return Redirect::action('roomController@own'); }