diff --git a/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitVenueRoomValidationRulesFactory.php b/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitVenueRoomValidationRulesFactory.php index b9642573..82f2a933 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitVenueRoomValidationRulesFactory.php +++ b/app/Http/Controllers/Apis/Protected/Summit/Factories/SummitVenueRoomValidationRulesFactory.php @@ -27,17 +27,10 @@ final class SummitVenueRoomValidationRulesFactory $rules = SummitAbstractLocationValidationRulesFactory::build($data, $update); - if($update) { - return array_merge([ - 'capacity' => 'sometimes|integer:min:0', - 'override_blackouts' => 'sometimes|boolean', - 'floor_id' => 'sometimes|integer', - ], $rules); - } - return array_merge([ 'capacity' => 'sometimes|integer:min:0', 'override_blackouts' => 'sometimes|boolean', + 'floor_id' => 'sometimes|integer', ], $rules); } } \ No newline at end of file diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php index 01551851..95e61c01 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php @@ -365,8 +365,34 @@ final class OAuth2PresentationCategoryGroupController } } + /** + * @param $summit_id + * @param $track_group_id + * @return mixed + */ public function deleteTrackGroupBySummit($summit_id, $track_group_id){ + try { + $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id); + if (is_null($summit)) return $this->error404(); + + $this->presentation_category_group_service->deleteTrackGroup($summit, $track_group_id); + + return $this->deleted(); + } + catch (ValidationException $ex1) { + Log::warning($ex1); + return $this->error412([$ex1->getMessage()]); + } + catch(EntityNotFoundException $ex2) + { + Log::warning($ex2); + return $this->error404(['message'=> $ex2->getMessage()]); + } + catch (Exception $ex) { + Log::error($ex); + return $this->error500($ex); + } } /** diff --git a/app/Models/Foundation/Summit/Events/Presentations/PrivatePresentationCategoryGroup.php b/app/Models/Foundation/Summit/Events/Presentations/PrivatePresentationCategoryGroup.php index 7fecef67..c3780de6 100644 --- a/app/Models/Foundation/Summit/Events/Presentations/PrivatePresentationCategoryGroup.php +++ b/app/Models/Foundation/Summit/Events/Presentations/PrivatePresentationCategoryGroup.php @@ -47,8 +47,8 @@ class PrivatePresentationCategoryGroup extends PresentationCategoryGroup /** * @ORM\ManyToMany(targetEntity="models\main\Group") * @ORM\JoinTable(name="PrivatePresentationCategoryGroup_AllowedGroups", - * joinColumns={@ORM\JoinColumn(name="PrivatePresentationCategoryGroupID", referencedColumnName="ID")}, - * inverseJoinColumns={@ORM\JoinColumn(name="GroupID", referencedColumnName="ID")} + * joinColumns={@ORM\JoinColumn(name="PrivatePresentationCategoryGroupID", referencedColumnName="ID", onDelete="CASCADE")}, + * inverseJoinColumns={@ORM\JoinColumn(name="GroupID", referencedColumnName="ID", onDelete="CASCADE")} * ) * @var Group[] */ diff --git a/app/Models/Foundation/Summit/Locations/SummitLocationConstants.php b/app/Models/Foundation/Summit/Locations/SummitLocationConstants.php index e13f38fa..05233f9a 100644 --- a/app/Models/Foundation/Summit/Locations/SummitLocationConstants.php +++ b/app/Models/Foundation/Summit/Locations/SummitLocationConstants.php @@ -15,6 +15,8 @@ use models\summit\SummitAirport; use models\summit\SummitExternalLocation; use models\summit\SummitHotel; use models\summit\SummitVenue; +use models\summit\SummitVenueRoom; + /** * Class SummitLocationConstants * @package App\Models\Foundation\Summit\Locations @@ -26,5 +28,6 @@ final class SummitLocationConstants SummitAirport::ClassName, SummitHotel::ClassName, SummitExternalLocation::ClassName, + SummitVenueRoom::ClassName ]; } \ No newline at end of file diff --git a/app/Services/Model/SummitLocationService.php b/app/Services/Model/SummitLocationService.php index 33f4ae08..be560715 100644 --- a/app/Services/Model/SummitLocationService.php +++ b/app/Services/Model/SummitLocationService.php @@ -693,7 +693,7 @@ final class SummitLocationService if(isset($data['floor_id'])){ $floor_id = intval($data['floor_id']); - $floor = $venue->getFloor($floor_id); + $floor = $venue->getFloor($floor_id); if(is_null($floor)){ throw new EntityNotFoundException @@ -854,7 +854,6 @@ final class SummitLocationService } } - // request to update order if (isset($data['order']) && intval($data['order']) != $room->getOrder()) { diff --git a/tests/OAuth2TrackGroupsApiTest.php b/tests/OAuth2TrackGroupsApiTest.php index bc5c5f77..b06f22ac 100644 --- a/tests/OAuth2TrackGroupsApiTest.php +++ b/tests/OAuth2TrackGroupsApiTest.php @@ -256,4 +256,33 @@ final class OAuth2TrackGroupsApiTest extends ProtectedApiTest $this->assertResponseStatus(201); } + /** + * @param int $summit_id + * @param int $track_group_id + */ + public function testDeleteExistentTrackGroup($summit_id = 24, $track_group_id = 85){ + + $params = [ + 'id' => $summit_id, + 'track_group_id' => $track_group_id + ]; + + $headers = [ + "HTTP_Authorization" => " Bearer " . $this->access_token, + "CONTENT_TYPE" => "application/json" + ]; + + $response = $this->action( + "DELETE", + "OAuth2PresentationCategoryGroupController@deleteTrackGroupBySummit", + $params, + [], + [], + [], + $headers + ); + + $content = $response->getContent(); + $this->assertResponseStatus(204); + } } \ No newline at end of file