diff --git a/app/Models/Foundation/Summit/Events/Presentations/Presentation.php b/app/Models/Foundation/Summit/Events/Presentations/Presentation.php index 410c0231..f700e546 100644 --- a/app/Models/Foundation/Summit/Events/Presentations/Presentation.php +++ b/app/Models/Foundation/Summit/Events/Presentations/Presentation.php @@ -724,4 +724,30 @@ class Presentation extends SummitEvent return false; } + /** + * @return bool + */ + public function fulfilSpeakersConditions(): bool { + $type = $this->type; + if(!$type instanceof PresentationType) return false; + + if($type->isUseModerator()){ + $count = $this->getModeratorId() > 0 ? 1 : 0; + $max = $type->getMaxModerators(); + $min = $type->getMinModerators(); + if($type->isModeratorMandatory() && $min > $count) return false; + if( $count > $max ) return false; + } + + if($type->isUseSpeakers()){ + $count = $this->speakers->count(); + $max = $type->getMaxSpeakers(); + $min = $type->getMinSpeakers(); + if($type->isAreSpeakersMandatory() && $min > $count) return false; + if( $count > $max ) return false; + } + + return true; + } + } diff --git a/app/Services/Model/PresentationService.php b/app/Services/Model/PresentationService.php index cce8ad15..550db030 100644 --- a/app/Services/Model/PresentationService.php +++ b/app/Services/Model/PresentationService.php @@ -410,7 +410,7 @@ final class PresentationService $presentation->setType($event_type); $presentation->setCategory($track); // add me as speaker - $presentation->addSpeaker($current_speaker); + //$presentation->addSpeaker($current_speaker); if (isset($data['tags'])) { $presentation->clearTags(); @@ -565,6 +565,13 @@ final class PresentationService ); } + if (!$presentation->fulfilSpeakersConditions()) { + throw new ValidationException + ( + sprintf("presentation %s is not allowed to mark as completed because does not fulfil speakers conditions", $presentation_id) + ); + } + $title = $presentation->getTitle(); $abtract = $presentation->getAbstract(); $level = $presentation->getLevel();