我正在使用 laravel spatie/laravel-feed 为我的博客网站生成提要
这是获取所有项目的方法
public static function getFeedItems()
{
return Post::all();
}
这是生成数据的方法
public function toFeedItem(): FeedItem
{
return FeedItem::create([
'id' => $this->id,
'title' => $this->title,
'summary' => $this->meta_description,
'updated' => $this->updated_at,
'link' => url('/', $this->slug),
'authorName' => $this->title,
]);
}
我已将其添加到我的 web.php 中
Route::feeds();
我已经在我的视图中添加了这样的链接
@include('feed::links')
当我访问此链接时,它显示此错误
https://github.com/spatie/laravel-feed这里有这样的
return FeedItem::create([
'id' => $this->id,
'title' => $this->title,
'summary' => $this->summary,
'updated' => $this->updated_at,
'link' => $this->link,
'authorName' => $this->authorName,
]);
在数组中我们不能这样使用
authorName' => $this->authorName,
使用解决方案
'author' => $this->authorName,
我必须同时设置两者才能修复此错误:
return FeedItem::create([
'id' => $this->id,
'title' => $this->title,
'summary' => $this->summary,
'updated' => $this->created_at,
'link' => $this->url,
'author' => "Author",
'authorName' => "Author name",
]);