";
\ No newline at end of file
diff --git a/src/Models/Product.php b/src/Models/Product.php
index c477d0b..c332e02 100644
--- a/src/Models/Product.php
+++ b/src/Models/Product.php
@@ -2,6 +2,7 @@
namespace Krzysiej\RyobiCrawler\Models;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -22,8 +23,17 @@ class Product extends Model
{
public $timestamps = true;
public $fillable = ['skuID'];
+
public function price(): HasMany
{
return $this->hasMany(Price::class);
}
+
+ protected function categories(): Attribute
+ {
+ return Attribute::make(
+ get: fn(string $value) => array_reverse(json_decode($value, 1)),
+ );
+ }
+
}
\ No newline at end of file