exchange/app/Models/Import.php

59 lines
1.4 KiB
PHP
Raw Normal View History

2022-01-10 12:03:57 +00:00
<?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;
2022-04-27 11:09:24 +00:00
// use Searchable;
2022-01-10 12:03:57 +00:00
protected $guarded = ['id'];
protected $casts = [
'registered_at' => 'date:d.m.Y'
];
2022-04-27 11:09:24 +00:00
// public function toSearchableArray()
// {
// return [
// 'id' => $this->id,
// 'title' => $this->title,
// 'group' => $this->group_id,
// 'locale' => $this->locale,
// ];
// }
2022-01-10 12:03:57 +00:00
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');
}
}