Update Article.php
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user