Skip to content

Commit 2710f24

Browse files
Update readme
1 parent 420ff20 commit 2710f24

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

README.md

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,33 @@ Optionally you can publish the view files:
7878
php artisan vendor:publish --provider="Spatie\Feed\FeedServiceProvider" --tag="views"
7979
```
8080

81+
### Upgrading from v1
8182

82-
### Automatically generate feed links
83+
Version 2 introduces some major API changes to the package, but upgrading shouldn't take too long.
8384

84-
To discover a feed, feed readers are looking for a tag in the head section of your html documents that looks like this:
85+
Replace the `FeedItem` interface with the new `Feedable` interface on your models. Visit the [Usage](#usage) usage for more details on implementing the new interface.
8586

86-
```html
87-
<link rel="alternate" type="application/atom+xml" title="News" href="/feed">
87+
```diff
88+
- use Spatie\Feed\FeedItem;
89+
+ use Spatie\Feed\Feedable;
90+
91+
- class NewsItem extends Model implements FeedItem
92+
+ class NewsItem extends Model implements Feedable
8893
```
8994

90-
You can add this to your `<head>` through a partial view.
91-
92-
```php
93-
@include('feed::links')
95+
Rename your config file from `laravel-feed.php` to `feed.php`.
96+
97+
```diff
98+
config/
99+
- laravel-feed.php
100+
+ feed.php
101+
```
102+
103+
Change the links `@include` directive.
104+
105+
```diff
106+
- @include('laravel-feed::feed-links')
107+
+ @include('feed::links')
94108
```
95109

96110
## Usage
@@ -102,10 +116,11 @@ First you must implement the `Feedable` interface on that model. `Feedable` expe
102116
```php
103117
// app/NewsItem.php
104118

119+
use Illuminate\Database\Eloquent\Model;
105120
use Spatie\Feed\Feedable;
106121
use Spatie\Feed\FeedItem;
107122

108-
class NewsItem implements Feedable
123+
class NewsItem extends Model implements Feedable
109124
{
110125
public function toFeedItem()
111126
{
@@ -122,13 +137,13 @@ class NewsItem implements Feedable
122137

123138
If you prefer, returning an associative array with the necessary keys will do the trick too.
124139

125-
```php
126140
```php
127141
// app/NewsItem.php
128142

143+
use Illuminate\Database\Eloquent\Model;
129144
use Spatie\Feed\Feedable;
130145

131-
class NewsItem implements Feedable
146+
class NewsItem extends Model implements Feedable
132147
{
133148
public function toFeedItem()
134149
{
@@ -191,6 +206,20 @@ The `items` key must point to a method that returns one of the following:
191206
- An array or collection of `FeedItem`s
192207
- An array or collection of arrays containing feed item values
193208

209+
### Automatically generate feed links
210+
211+
To discover a feed, feed readers are looking for a tag in the head section of your html documents that looks like this:
212+
213+
```html
214+
<link rel="alternate" type="application/atom+xml" title="News" href="/feed">
215+
```
216+
217+
You can add this to your `<head>` through a partial view.
218+
219+
```php
220+
@include('feed::links')
221+
```
222+
194223
## Changelog
195224

196225
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

0 commit comments

Comments
 (0)