Update (route)

This commit is contained in:
2023-11-21 21:24:40 +08:00
parent 27035c1a9b
commit 4827130183
6 changed files with 60 additions and 5 deletions

View File

@@ -8,6 +8,9 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Spatie\Feed\Feedable;
use Spatie\Feed\FeedItem;
/**
* Class RssPost
@@ -33,7 +36,7 @@
* @property Carbon|null $updated_at
* @property Category|null $category
*/
class RssPost extends Model
class RssPost extends Model implements Feedable
{
protected $table = 'rss_posts';
@@ -68,4 +71,31 @@ public function category()
{
return $this->belongsTo(Category::class);
}
public function getAllKeywordsAttribute()
{
if (!is_empty($this->keyword_list))
{
return array_unique(explode(",",$this->keyword_list));
}
return [];
}
public function toFeedItem(): FeedItem
{
return FeedItem::create([
'id' => $this->id,
'title' => $this->title,
'summary' => $this->bites,
'updated' => $this->published_at,
// 'link' => route('front.post', ['slug' => $this->slug, 'category_slug' => $this->category->slug]),
'authorName' => 'FutureWalker',
]);
}
public static function getFeedItems()
{
return self::with('category')->where('status', 'published')->latest('published_at')->take(60)->get();
}
}