diff --git a/app/Article.php b/app/Article.php index 20f99f8..c811c9d 100644 --- a/app/Article.php +++ b/app/Article.php @@ -2,6 +2,7 @@ namespace App; +use App\Models\Category; use GoldSpecDigital\LaravelEloquentUUID\Database\Eloquent\Uuid; use Illuminate\Database\Eloquent\Model; use App\Source; @@ -32,7 +33,7 @@ class Article extends Model */ protected $guarded = []; - /** + /** * The attributes that should be mutated to dates. * * @var array @@ -61,4 +62,15 @@ class Article extends Model { return $this->belongsToMany(Topic::class)->withTimestamps(); } + + public function category() + { + return $this->belongsTo(Category::class); + } + + public function ScopeRecentArticles() + { + return $this->with('source', 'topics') + ->latest("published_date"); + } }