Skip to content

Commit 7ecfbd2

Browse files
Update README.md
1 parent 5ccdffd commit 7ecfbd2

File tree

1 file changed

+6
-52
lines changed

1 file changed

+6
-52
lines changed

README.md

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,6 @@ class UserFeed extends Feed
107107
->where('created_at', '>', now()->subYear());
108108
}
109109

110-
// You can remove to overwrite of the method,
111-
// if you do not need to wrap the elements into the general tag.
112-
public function rootItem(): ?string
113-
{
114-
return 'users';
115-
}
116-
117-
public function filename(): string
118-
{
119-
return 'users-feed.xml';
120-
}
121-
122110
public function item(Model $model): FeedItem
123111
{
124112
return new UserFeedItem($model);
@@ -138,42 +126,18 @@ use DragonCode\LaravelFeed\FeedItem;
138126
/** @property-read \App\Models\User $model */
139127
class UserFeedItem extends FeedItem
140128
{
141-
public function attributes(): array
142-
{
143-
return [
144-
'id' => $this->model->id,
145-
'created_at' => $this->model->created_at->format('Y-m-d'),
146-
];
147-
}
148-
149129
public function toArray(): array
150130
{
151131
return [
152132
'name' => $this->model->name,
153133
'email' => $this->model->email,
154134

155135
'header' => [
156-
'@cdata' => '<h1>' . $this->model->name . '</h1>',
157-
],
158-
159-
'names' => [
160-
'Good guy' => [
161-
'@attributes' => [
162-
'my-key-1' => 'my value 1',
163-
'my-key-2' => 'my value 2',
164-
],
165-
166-
'name' => 'Luke Skywalker',
167-
'weapon' => 'Lightsaber',
168-
],
169-
170-
'Bad guy' => [
171-
'name' => [
172-
'@cdata' => '<h1>Sauron</h1>',
173-
],
174-
175-
'weapon' => 'Evil Eye',
136+
'@attributes' => [
137+
'my-key-1' => 'my value 1',
138+
'my-key-2' => 'my value 2',
176139
],
140+
'@cdata' => '<h1>' . $this->model->name . '</h1>',
177141
],
178142
];
179143
}
@@ -185,20 +149,10 @@ According to this example, the XML file with the following contents will be gene
185149
```xml
186150
<?xml version="1.0" encoding="UTF-8"?>
187151
<users>
188-
<user id="1" created_at="2025-08-30">
152+
<user>
189153
<name>John Doe</name>
190154
<email>[email protected]</email>
191-
<header><![CDATA[<h1>John Doe</h1>]]></header>
192-
<names>
193-
<Good_guy my-key-1="my value 1" my-key-2="my value 2">
194-
<name>Luke Skywalker</name>
195-
<weapon>Lightsaber</weapon>
196-
</Good_guy>
197-
<Bad_guy>
198-
<name><![CDATA[<h1>Sauron</h1>]]></name>
199-
<weapon>Evil Eye</weapon>
200-
</Bad_guy>
201-
</names>
155+
<header my-key-1="my value 1" my-key-2="my value 2"><![CDATA[<h1>John Doe</h1>]]></header>
202156
</user>
203157
</users>
204158
```

0 commit comments

Comments
 (0)