'integer', ]; protected static function boot() { parent::boot(); static::creating(function ($news) { if (empty($news->slug)) { $news->slug = Str::slug($news->title); } }); } public function scopePublished($query) { return $query->where('status', 'published'); } public function scopeByCategory($query, $category) { return $query->where('category', $category); } public function incrementViews() { $this->increment('views'); } public function getImageUrlAttribute() { if ($this->image) { return asset('storage/' . $this->image); } return null; } }