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