I have this method in my Laravel 4 controller:
public static function getDelegateData($id, $status)
{
$event = Event::find($id);
foreach ($event->delegates as $delegate) {
$delegate->status = DelegateStatus::find($delegate->pivot->delegate_status_id)->status;
if($delegate->status == $status) {
$total[] = $delegate->id;
}
}
$data = "There are currently a total of $status delegates booked on to this event.";
$data .= '<ul>';
foreach ($event->delegates as $delegate) {
$delegate->status = DelegateStatus::find($delegate->pivot->delegate_status_id)->status;
if($delegate->status == $status) {
$data .= '<li>';
$data .= $delegate->contact->first_name . ' ' . $delegate->contact->last_name;
$data .= '</li>';
}
}
$data .= '</ul>';
return $data;
}
I'm having trouble counting (using count()) the items in the $total array. How can I do this? Thanks.