Skip to content

Commit

Permalink
Betters feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislawfortonski committed Apr 10, 2021
1 parent 571b0fc commit f432304
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,25 @@ public function scopeSearch($query, $searchData)
public function toFeedItem()
{
$content = $this->content->first();
return FeedItem::create()
$feed = FeedItem::create()
->id($this->id)
->title($content->title)
->summary($content->description)
->updated($content->updated_at)
->link(route('posts.show', [app()->getLocale(), $content->url]))
->author($this->author->full_name);

$categories = $this->categories()->has('content')->get();
$params = [];
foreach($categories as $category){
$content = $category->content->first();
if (!empty($content)){
$params[] = $content->title;
}
}
if (count($params) > 0)
$feed->category(...$params);
return $feed;
}

public static function getFeedItems()
Expand Down

0 comments on commit f432304

Please sign in to comment.