laravel-nami-api/src/Region.php

29 lines
543 B
PHP
Raw Normal View History

2021-04-10 00:48:04 +02:00
<?php
namespace Zoomyboy\LaravelNami;
use Illuminate\Database\Eloquent\Model;
2022-03-11 20:20:00 +01:00
class Region extends Model implements Nullable
{
2021-04-10 00:48:04 +02:00
protected $guarded = [];
2022-03-11 20:20:00 +01:00
public static function getNullValue()
{
return 23;
}
2022-03-11 20:20:00 +01:00
public static function fromNami($item)
{
2021-04-10 00:48:04 +02:00
return new self([
'id' => $item['id'],
2022-03-11 20:20:00 +01:00
'name' => preg_replace('/\s*\(.*?\)/', '', $item['descriptor']),
2021-04-10 00:48:04 +02:00
]);
}
2022-03-11 20:20:00 +01:00
public function getIsNullAttribute()
{
return $this->id == self::getNullValue();
}
2021-04-10 00:48:04 +02:00
}