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()
|
|
|
|
{
|
2021-05-14 18:38:47 +02:00
|
|
|
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()
|
|
|
|
{
|
2021-05-14 18:38:47 +02:00
|
|
|
return $this->id == self::getNullValue();
|
|
|
|
}
|
2021-04-10 00:48:04 +02:00
|
|
|
}
|