You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.9 KiB
76 lines
1.9 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\AdminTranslationService;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ParkingSpaceAttributes extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'parking_space_attributes';
|
|
|
|
protected $fillable = [
|
|
'attributes',
|
|
'import_diagram'
|
|
];
|
|
|
|
protected $hidden
|
|
= [
|
|
'created_at',
|
|
'updated_at',
|
|
'deleted_at'
|
|
];
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function getList(): array
|
|
{
|
|
return self::query()->get()->select(
|
|
['id', 'attributes']
|
|
)->toArray();
|
|
}
|
|
|
|
public static function getTypeList(): array
|
|
{
|
|
return self::query()->where('is_default', 0)->get()->select(
|
|
['id', 'attributes']
|
|
)->each(function ($item) {
|
|
$item['attributes']
|
|
= AdminTranslationService::getTranslationTypeName(
|
|
$item['id'],
|
|
2,
|
|
$item['attributes']
|
|
);
|
|
return $item;
|
|
})->toArray();
|
|
}
|
|
|
|
public static function getAttr($id)
|
|
{
|
|
$attributes = self::query()->where('id', $id)->value('attributes') ?? '';
|
|
return AdminTranslationService::getTranslationTypeName(
|
|
$id,
|
|
2,
|
|
$attributes);
|
|
}
|
|
|
|
public static function getData(): array
|
|
{
|
|
return self::query()->select(['id', 'attributes'])->get()
|
|
->each(
|
|
function ($item) {
|
|
$item['attributes']
|
|
= AdminTranslationService::getTranslationTypeName(
|
|
$item['id'],
|
|
2,
|
|
$item['attributes']
|
|
);
|
|
return $item;
|
|
}
|
|
)->toArray() ?? [];
|
|
}
|
|
}
|
|
|