'datetime', 'publicado' => 'boolean', 'destacado' => 'boolean', 'orden' => 'integer', ]; // ✅ se incluirá en el JSON protected $appends = ['imagen_url']; public function getImagenUrlAttribute(): ?string { // 1) Si en BD hay una URL externa, úsala if (!empty($this->attributes['imagen_url'])) { return $this->attributes['imagen_url']; } // 2) Si hay imagen en storage, genera URL absoluta if (!empty($this->imagen_path)) { return url(Storage::disk('public')->url($this->imagen_path)); } return null; } protected static function booted(): void { static::saving(function (Noticia $noticia) { if (!$noticia->slug) { $noticia->slug = Str::slug($noticia->titulo); } }); } }