laravel-nami-api/src/Region.php

29 lines
595 B
PHP
Raw Normal View History

2021-04-10 00:48:04 +02:00
<?php
namespace Zoomyboy\LaravelNami;
use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Model;
use Zoomyboy\LaravelNami\Nullable;
2021-04-10 00:48:04 +02:00
class Region extends Model implements Nullable {
2021-04-10 00:48:04 +02:00
protected $guarded = [];
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'])
]);
}
public function getIsNullAttribute() {
return $this->id == self::getNullValue();
}
2021-04-10 00:48:04 +02:00
}