<?php
/**
 *
 * User: Artur Pilch <artur.pi@modulesgarden.com>
 * Date: 2018-08-07
 * Time: 09:21
 */

namespace ModulesGarden\HostingQuotaNotifications\App\Helper\Models;

use ModulesGarden\HostingQuotaNotifications\Core\Models\Whmcs\Admins;
use \Illuminate\Database\Capsule\Manager as DB;



class Admin
{
    public static function getAdminsAsKeyIdNameValue()
    {
        return Admins::select('id', DB::raw('CONCAT(firstname, " ",lastname) AS name'))->orderBy('firstname')->get()->pluck('name', 'id')->toArray();
    }

    public static function get($id)
    {
        return Admins::where('id', '=', $id)->get()->first();
    }

    public static function getValueById($id, $value)
    {
        if(!$id || !$value)
        {
            return;
        }
        return Admins::where('id', '=', $id)->first()->value($value);
    }

}