https://laravel-news.com/package/spatie-laravel-feed в качестве исходных данных
Я установил «spatie/laravel-feed»: «^4.4» и в файл добавил путь к моей модели:
Код: Выделить всё
'main' => [
'items' => 'App\Models\News@getActiveNewsFeedItems',
Код: Выделить всё
use Spatie\Feed\Feedable;
use Spatie\Feed\FeedItem;
class News extends Model implements Feedable
{
protected $primaryKey = 'id';
public $timestamps = false;
protected $table = 'news';
public static function getActiveNewsFeedItems()
{
return News::getByPublished(NewsPublishedEnum::PUBLISHED->value)->limit(50)->orderBy('published', 'desc')->get();
}
public function toFeedItem(): FeedItem
{
return FeedItem::create()
->id($this->slug)
->title($this->title)
->summary($this->content_shortly)
->updated($this->published_at)
->link(route('news.show', $this->slug))
->authorName($this->creator->name)
->authorEmail($this->creator->email);
}
Код: Выделить всё
Но на любом из маршрутов:
Код: Выделить всё
http://local-news-publishers.com/feeds.main
http://local-news-publishers.com/feeds
http://local-news-publishers.com/feed
Я получил ошибку:
Код: Выделить всё
404 NOT FOUND
Код: Выделить всё
GET|HEAD / ................................................................................................................................... feeds.main › Spatie\Feed › FeedController
Подробнее здесь: https://stackoverflow.com/questions/784 ... -is-opened