29 lines
543 B
PHP
29 lines
543 B
PHP
<?php
|
|
|
|
namespace Zoomyboy\LaravelNami;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Region extends Model implements Nullable
|
|
{
|
|
protected $guarded = [];
|
|
|
|
public static function getNullValue()
|
|
{
|
|
return 23;
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|