Update Article.php
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
|
use App\Models\Category;
|
||||||
use GoldSpecDigital\LaravelEloquentUUID\Database\Eloquent\Uuid;
|
use GoldSpecDigital\LaravelEloquentUUID\Database\Eloquent\Uuid;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Source;
|
use App\Source;
|
||||||
@@ -61,4 +62,15 @@ class Article extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(Topic::class)->withTimestamps();
|
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