improve customer timetable
This commit is contained in:
@@ -83,4 +83,56 @@ class EventRegistration extends \yii\db\ActiveRecord
|
||||
public function getCustomerClass(){
|
||||
return Customer::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EventRegistration $eventRegistration
|
||||
*/
|
||||
public static function isActive($eventRegistration){
|
||||
if ( !isset($eventRegistration ) ){
|
||||
return false;
|
||||
}
|
||||
if ( isset($eventRegistration->canceled_at ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( isset($eventRegistration->deleted_at ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EventRegistration $eventRegistration
|
||||
*/
|
||||
public static function isForCustomer($eventRegistration,$idCustomer){
|
||||
if ( !isset($eventRegistration ) ){
|
||||
return false;
|
||||
}
|
||||
if ( !isset($eventRegistration->id_customer ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
return $eventRegistration->id_customer == $idCustomer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EventRegistration[] $eventRegistrations
|
||||
*/
|
||||
public static function filterActive($eventRegistrations){
|
||||
return array_filter($eventRegistrations, EventRegistration::class.'::isActive' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EventRegistration[] $eventRegistrations
|
||||
*/
|
||||
public static function filterForCustomer($eventRegistrations,$idCustomer){
|
||||
$result = [];
|
||||
foreach ($eventRegistrations as $eventRegistration){
|
||||
if ( EventRegistration::isForCustomer($eventRegistration,$idCustomer)){
|
||||
$result[] = $eventRegistration;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user