From 83b01a84df2182646a7856727213b465de285c1c Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Thu, 28 Apr 2022 12:26:55 -0700 Subject: [PATCH] fix owned url --- app/Models/Owned.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Models/Owned.php b/app/Models/Owned.php index 59f63b2..4d3db35 100644 --- a/app/Models/Owned.php +++ b/app/Models/Owned.php @@ -5,6 +5,7 @@ use App\Traits\Categorizable; use App\Traits\Imageable; use App\Traits\Ownable; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -28,6 +29,15 @@ class Owned extends Model // injected by trait: categories (many-to-many polymorphic) + /* --------------------------------------------------------------------------------- url ---- */ + + protected function url() : Attribute + { + return Attribute::make( + get: fn () => "/{$this->slug}", + ); + } + /* ------------------------------------------------------------------------------- store ---- */ public static function store(array $validated) : static