/** * Run the database seeds. * * @return void */ public function run() { $residences = array(["name" => "Foobar Res", "location" => "Integer Drive", "conferenceID" => self::TARGET_CONF], ["name" => "Barbaz Res", "location" => "XYZ Ave", "conferenceID" => self::TARGET_CONF]); foreach ($residences as $res) { Residence::create($res); } $types = array(["name" => "TypeA", "capacity" => 4, "accessible" => true], ["name" => "TypeB", "capacity" => 4, "accessible" => false], ["name" => "TypeA-R2", "capacity" => 4, "accessible" => true]); foreach ($types as $ty) { RoomType::create($ty); } $sets = array(["name" => "104A-104D", "residenceID" => 1, "typeID" => 1], ["name" => "204B-204Y", "residenceID" => 1, "typeID" => 2], ["name" => "21-29", "residenceID" => 2, "typeID" => 3]); foreach ($sets as $set) { RoomSet::create($set); } }
public function roomsInSet($confId, $setId) { if (!Entrust::can(PermissionNames::ConferenceRoomEdit($confId))) { return response("", 403); } $set = RoomSet::with("residence")->find($setId); if (is_null($set) || $set->residence->conferenceID != $confId) { return response()->json(["message" => "no_such_set"], 404); } return UserRoom::selectRaw('roomName, count(*) as currentUsers')->where('roomSetID', $set->id)->groupBy('roomName')->get(); }
public function deleteRoomSet($confId, $roomSetId) { if (!Entrust::can(PermissionNames::ConferenceRoomEdit($confId))) { return response("", 403); } $set = RoomSet::with("residence")->find($roomSetId); if (!isset($set) || $set->residence->conferenceID != $confId) { return response("", 404); } $set->delete(); Log::info("Room set {$roomSetId} of conference {$confId} deleted"); }