slug)) { $product->slug = Str::slug($product->name); } }); static::updating(function ($product) { if ($product->isDirty('name') && empty($product->slug)) { $product->slug = Str::slug($product->name); } }); } public function getImageAttribute($value) { if (!$value) { return null; } // If it's already a full URL, return as is if (str_starts_with($value, 'http')) { return $value; } // If it starts with 'storage/', it's already formatted if (str_starts_with($value, 'storage/')) { return asset($value); } // Otherwise, prepend 'storage/' return asset('storage/' . $value); } }