Basic implementation event signup
This commit is contained in:
		
							
								
								
									
										53
									
								
								modules/event-participants/Requests/class-eatingrequest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								modules/event-participants/Requests/class-eatingrequest.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace Bdp\Modules\EventParticipants\Reqeust;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
use Bdp\Modules\EventParticipants\Models\Event;
 | 
			
		||||
use Bdp\Modules\EventParticipants\Models\EventParticipant;
 | 
			
		||||
use Carbon\Carbon;
 | 
			
		||||
 | 
			
		||||
class EatingRequest {
 | 
			
		||||
	public static function send(array $participantList, string $eatingHabit, \DateTime $date) {
 | 
			
		||||
		$participantCount = [ '1' => 0, '2' => 0, '3' => 0 ];
 | 
			
		||||
 | 
			
		||||
		foreach ($participantList as $participant) {
 | 
			
		||||
				if ( $participant->essgewohnheit !== $eatingHabit ) {
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$anreise = \DateTime::createFromFormat( 'Y-m-d', $participant->anreise );
 | 
			
		||||
				$abreise = \DateTime::createFromFormat( 'Y-m-d', $participant->abreise );
 | 
			
		||||
 | 
			
		||||
				if ( $anreise->getTimestamp() < $date->getTimestamp() && $abreise->getTimestamp() > $date->getTimestamp() ) {
 | 
			
		||||
					$participantCount['1']++;
 | 
			
		||||
					$participantCount['2']++;
 | 
			
		||||
					$participantCount['3']++;
 | 
			
		||||
				} elseif ( $anreise->getTimestamp() == $date->getTimestamp() ) { // Anreisetag
 | 
			
		||||
					if ( $participant->anreise_essen == 3 ) {
 | 
			
		||||
						$participantCount['1']++;
 | 
			
		||||
						$participantCount['2']++;
 | 
			
		||||
						$participantCount['3']++;
 | 
			
		||||
					} elseif ( $participant->anreise_essen == 2 ) {
 | 
			
		||||
						$participantCount['2']++;
 | 
			
		||||
						$participantCount['3']++;
 | 
			
		||||
					} elseif ( $participant->anreise_essen == 1 ) {
 | 
			
		||||
						$participantCount['3']++;
 | 
			
		||||
					}
 | 
			
		||||
				} elseif ( $abreise->getTimestamp() == $date->getTimestamp() ) { // Abreisetag
 | 
			
		||||
					if ( $participant->abreise_essen == 3 ) {
 | 
			
		||||
						$participantCount['1']++;
 | 
			
		||||
						$participantCount['2']++;
 | 
			
		||||
						$participantCount['3']++;
 | 
			
		||||
					} elseif ( $participant->abreise_essen == 2 ) {
 | 
			
		||||
						$participantCount['1']++;
 | 
			
		||||
						$participantCount['2']++;
 | 
			
		||||
					} elseif ( $participant->abreise_essen == 1 ) {
 | 
			
		||||
						$participantCount['1']++;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		return $participantCount;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user