<?php

namespace App\Models\Managers;

use App\Models\Loaders\UsersLoader;
use App\Models\Objects\Contact;

class ContactManager
{
    private string $imgDir;

    public function __construct(
        private UsersLoader $usersLoader,
    ) {
        $this->imgDir = config('directories.images');
    }

    public function getContacts(): array
    {
        $data = $this->usersLoader->getContacts();

        $contacts = [];
        foreach($data as $row) {
            $contact = new Contact();
            $contact->setImgPath($this->imgDir);
            $contact->setAttributes($row);
            $contacts[] = $contact;
        }

        return $contacts;
    }
}
