<?php

namespace App\Models\Loaders;

use App\Models\ORM\User as Contact;

class UsersLoader
{
    public function getContacts(): array
    {
        $data = Contact::select(
            "users.id",
            "users.name as first_name",
            "users.last_name",
            "users.phone",
            "users.email",
            "users.vk_id as web_page",
            "users.img_large",
            "users.img_small",
            "contact_roles.description as role"
        )->join("contact_roles", "users.contact_role", "=", "contact_roles.id")
            ->where("users.use_as_contact", 1)
            ->get();

        return $data ? $data->toArray() : [];
    }
}
