This package generates rss feeds for any of the models that has a feed data.
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
You can install the package via composer:
$ composer require spatie/laravel-rss
Next up, the service provider must be registered:
// Laravel5: config/app.php
'providers' => [
...
Spatie\Rss\RssServiceProvider::class,
];
Next, you must publish the config file:
php artisan vendor:publish --provider="Spatie\Rss\RssServiceProvider"
This is the content of the published file laravel-rss.php: You must change it to fit your needs.
return [
'feeds' => [
[
'items' => '', // Fill in the class with a method that returns a collection of items that must come in the feed. e.g.: 'App\Repositories\NewsItemRepository@getAllOnline'
'url' => '', // feed url, on which the feeds would be shown
'meta' => [
'link' => '',
'title' => '',
'updated' => \Carbon\Carbon::now()->toATOMString(),
'description' => '',
]
],
],
];
The model that would have feeds must implement RssItem interface and have a method called getFeedData that would return array with the specific values as shown in the example here below: e.g.:
class NewsItem extends ModuleModel implements RssItem
{
...
public function getFeedData()
{
return [
'title' => $this->name,
'id' => $this->id,
'updated' => $this->updated_at,
'summary' => $this->present()->excerpt,
'link' => action('Front\NewsItemController@detail', [$this->url]),
];
}
}
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
The MIT License (MIT). Please see License File for more information.