<?php

namespace App\Models;

use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Import extends Model
{
    use HasFactory;
    // use Searchable;

    protected $guarded = ['id'];
    protected $casts = [
        'registered_at' => 'date:d.m.Y'
    ];

    // public function toSearchableArray()
    // {
    //     return [
    //         'id' => $this->id,
    //         'title' => $this->title,
    //         'group' => $this->group_id,
    //         'locale' => $this->locale,
    //     ];
    // }

    public static function countries($ids = [])
    {
        return self::selectRaw('country')
            ->where('group_id', request('group'))
            ->where('locale', app()->getLocale())
            // ->whereIn('id', $ids)
            ->distinct()
            ->pluck('country');
    }

    public static function currencies($ids = [])
    {
        return self::selectRaw('currency')
            ->where('group_id', request('group'))
            ->where('locale', app()->getLocale())
            // ->whereIn('id', $ids)
            ->distinct()
            ->pluck('currency');
    }

    public static function units($ids = [])
    {
        return self::selectRaw('unit')
            ->where('group_id', request('group'))
            ->where('locale', app()->getLocale())
            // ->whereIn('id', $ids)
            ->distinct()
            ->pluck('unit');
    }
}
