use App\Models\Company\Company;
use App\Models\Company\Meeting;
class GroupMeetingsViewHelper
{
//
public static function show(Meeting $meeting, Company $company): array
{
public static function show(Meeting $meeting, Company $company): array
{
$participants = $meeting->employees()
->orderBy('last_name', 'asc')
->get();
$participantsCollection = collect([]);
$guestsCollection = collect([]);
foreach ($participants as $employee) {
if ((bool) $employee->pivot->was_a_guest) {
$guestsCollection->push([
'id' => $employee->id,
'name' => $employee->name,
'avatar' => ImageHelper::getAvatar($employee, 23),
'attended' => (bool) $employee->pivot->attended,
'was_a_guest' => true,
'url' => route('employees.show', [
'company' => $company,
'employee' => $employee,
]),
]);
} else {
$participantsCollection->push([
'id' => $employee->id,
'name' => $employee->name,
'avatar' => ImageHelper::getAvatar($employee, 23),
'attended' => (bool) $employee->pivot->attended,
'was_a_guest' => false,
'url' => route('employees.show', [
'company' => $company,
'employee' => $employee,
]),
]);
}
}
//
}
//
}