From 65384250d6c100bc4020a3d89bf3203423ffa0fa Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Tue, 26 Mar 2024 20:52:32 -0400 Subject: [PATCH] Add attribute --- app/Models/Allocation.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Models/Allocation.php b/app/Models/Allocation.php index 18d6e269f..6a7d45db7 100644 --- a/app/Models/Allocation.php +++ b/app/Models/Allocation.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Exceptions\Service\Allocation\ServerUsingAllocationException; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** @@ -111,9 +112,16 @@ class Allocation extends Model return !is_null($this->ip_alias); } + public function address(): Attribute + { + return Attribute::make( + get: fn () => "$this->ip:$this->port", + ); + } + public function toString(): string { - return sprintf('%s:%s', $this->ip, $this->port); + return $this->address; } /**