Add attribute

This commit is contained in:
Lance Pioch 2024-03-26 20:52:32 -04:00
parent 3e7bff2446
commit 65384250d6

View File

@ -3,6 +3,7 @@
namespace App\Models; namespace App\Models;
use App\Exceptions\Service\Allocation\ServerUsingAllocationException; use App\Exceptions\Service\Allocation\ServerUsingAllocationException;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** /**
@ -111,9 +112,16 @@ class Allocation extends Model
return !is_null($this->ip_alias); return !is_null($this->ip_alias);
} }
public function address(): Attribute
{
return Attribute::make(
get: fn () => "$this->ip:$this->port",
);
}
public function toString(): string public function toString(): string
{ {
return sprintf('%s:%s', $this->ip, $this->port); return $this->address;
} }
/** /**