@@ -78,19 +78,33 @@ Optionally you can publish the view files:
78
78
php artisan vendor:publish --provider=" Spatie\Feed\FeedServiceProvider" --tag=" views"
79
79
```
80
80
81
+ ### Upgrading from v1
81
82
82
- ### Automatically generate feed links
83
+ Version 2 introduces some major API changes to the package, but upgrading shouldn't take too long.
83
84
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.
85
86
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
88
93
```
89
94
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')
94
108
```
95
109
96
110
## Usage
@@ -102,10 +116,11 @@ First you must implement the `Feedable` interface on that model. `Feedable` expe
102
116
``` php
103
117
// app/NewsItem.php
104
118
119
+ use Illuminate\Database\Eloquent\Model;
105
120
use Spatie\Feed\Feedable;
106
121
use Spatie\Feed\FeedItem;
107
122
108
- class NewsItem implements Feedable
123
+ class NewsItem extends Model implements Feedable
109
124
{
110
125
public function toFeedItem()
111
126
{
@@ -122,13 +137,13 @@ class NewsItem implements Feedable
122
137
123
138
If you prefer, returning an associative array with the necessary keys will do the trick too.
124
139
125
- ``` php
126
140
``` php
127
141
// app/NewsItem.php
128
142
143
+ use Illuminate\Database\Eloquent\Model;
129
144
use Spatie\Feed\Feedable;
130
145
131
- class NewsItem implements Feedable
146
+ class NewsItem extends Model implements Feedable
132
147
{
133
148
public function toFeedItem()
134
149
{
@@ -191,6 +206,20 @@ The `items` key must point to a method that returns one of the following:
191
206
- An array or collection of ` FeedItem ` s
192
207
- An array or collection of arrays containing feed item values
193
208
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
+
194
223
## Changelog
195
224
196
225
Please see [ CHANGELOG] ( CHANGELOG.md ) for more information what has changed recently.
0 commit comments