Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions docs/snippets/advanced-directive-array.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<array_directive>

<user>
<name>Ilene Renner</name>
<avatar>https://via.placeholder.com/640x480.png/0099bb?text=consequatur</avatar>
<avatar>https://via.placeholder.com/640x480.png/00ee33?text=ut</avatar>
<images name="consequatur ipsum fuga">https://via.placeholder.com/640x480.png/008866?text=magnam</images>
<images name="a consequatur est">https://via.placeholder.com/640x480.png/0099aa?text=optio</images>
<name>Mr. Nathanael Davis</name>
<avatar>https://via.placeholder.com/640x480.png/0055ff?text=in</avatar>
<avatar>https://via.placeholder.com/640x480.png/001155?text=aperiam</avatar>
<images name="amet sint dolor">https://via.placeholder.com/640x480.png/00cc66?text=excepturi</images>
<images name="recusandae natus iure">https://via.placeholder.com/640x480.png/00cc99?text=velit</images>
</user>
<user>
<name>Dr. Richard Rogahn Jr.</name>
<avatar>https://via.placeholder.com/640x480.png/00aa55?text=et</avatar>
<avatar>https://via.placeholder.com/640x480.png/00aa00?text=consequuntur</avatar>
<images name="veniam consequatur quia">https://via.placeholder.com/640x480.png/00ff88?text=asperiores</images>
<images name="asperiores quia voluptas">https://via.placeholder.com/640x480.png/0011aa?text=unde</images>
</user>
<name>Ms. Elouise Deckow</name>
<avatar>https://via.placeholder.com/640x480.png/00bb66?text=voluptas</avatar>
<avatar>https://via.placeholder.com/640x480.png/00cc99?text=pariatur</avatar>
<images name="non autem reprehenderit">https://via.placeholder.com/640x480.png/009922?text=dolores</images>
<images name="voluptas corrupti fugiat">https://via.placeholder.com/640x480.png/005533?text=quae</images>
</user>

</array_directive>
6 changes: 3 additions & 3 deletions docs/snippets/advanced-directive-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace App\Feeds;

use App\Feeds\Info\AttributesDirectiveFeedInfo;
use App\Feeds\Items\AttributesDirectiveFeedItem;
use App\Models\User;
use DragonCode\LaravelFeed\Feeds\Feed;
use DragonCode\LaravelFeed\Feeds\Info\FeedInfo;
use DragonCode\LaravelFeed\Feeds\Items\FeedItem;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use App\Feeds\Info\AttributesDirectiveFeedInfo;
use App\Feeds\Items\AttributesDirectiveFeedItem;
use App\Models\User;

class AttributesDirectiveFeed extends Feed
{
Expand Down
16 changes: 10 additions & 6 deletions docs/snippets/advanced-directive-attributes.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<company since="1983"/>
<attributes_directive>

<company since="2013"/>
<url>https://example.com</url>

<user>
<name>Grace Luettgen</name>
<contact email="vdeckow@example.org" phone="555-000-1"/>
<name>Loren Shields</name>
<contact email="friesen.lewis@example.com" phone="555-000-1"/>
</user>
<user>
<name>Stanton Dach DVM</name>
<contact email="richmond.runolfsson@example.com" phone="555-000-2"/>
</user>
<name>Matilde Kohler DVM</name>
<contact email="casey.koch@example.net" phone="555-000-2"/>
</user>

</attributes_directive>
14 changes: 9 additions & 5 deletions docs/snippets/advanced-directive-cdata.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<cdata_directive>

<user>
<name><![CDATA[<h1>Prof. Clifford Kirlin IV</h1>]]></name>
<email>skiles.foster@example.net</email>
<name><![CDATA[<h1>Haley Purdy</h1>]]></name>
<email>elmo56@example.com</email>
</user>
<user>
<name><![CDATA[<h1>Nelle Frami</h1>]]></name>
<email>knader@example.com</email>
</user>
<name><![CDATA[<h1>Pearl Kozey</h1>]]></name>
<email>eusebio04@example.com</email>
</user>

</cdata_directive>
14 changes: 9 additions & 5 deletions docs/snippets/advanced-directive-mixed.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<mixed_directive>

<user>
<name>Palma Stokes</name>
<name>Luis Beer DVM</name>
<some>
<first>Foo</first>
<second>roscoe51@example.org</second>
<second>kane.nader@example.com</second>
</some>
</user>
<user>
<name>Geoffrey Treutel</name>
<name>Claud Quigley IV</name>
<some>
<first>Foo</first>
<second>heath.mosciski@example.org</second>
<second>talon09@example.net</second>
</some>
</user>
</user>

</mixed_directive>
14 changes: 9 additions & 5 deletions docs/snippets/advanced-directive-value.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<value_directive>

<user>
<name>Josiane Heller</name>
<contact type="email">uriah41@example.com</contact>
<name>Isac Hamill</name>
<contact type="email">mathias01@example.org</contact>
</user>
<user>
<name>Jermey Krajcik</name>
<contact type="email">schowalter.triston@example.org</contact>
</user>
<name>Letha Lubowitz</name>
<contact type="email">runolfsson.claude@example.org</contact>
</user>

</value_directive>
4 changes: 2 additions & 2 deletions docs/snippets/advanced-element-attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace App\Feeds;

use App\Feeds\Items\AttributeFeedItem;
use App\Models\User;
use DragonCode\LaravelFeed\Feeds\Feed;
use DragonCode\LaravelFeed\Feeds\Items\FeedItem;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use App\Feeds\Items\AttributeFeedItem;
use App\Models\User;

class AttributeFeed extends Feed
{
Expand Down
14 changes: 9 additions & 5 deletions docs/snippets/advanced-element-attribute.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<user created_at="2025-09-04 20:05:40">
<attribute>

<user created_at="2025-09-04 20:11:33">
<id>1</id>
<name>Jakayla Vandervort</name>
<name>Dr. Timmothy Howell MD</name>
</user>
<user created_at="2025-09-04 20:05:40">
<user created_at="2025-09-04 20:11:33">
<id>2</id>
<name>Prof. Garrick Gottlieb</name>
</user>
<name>Marcel Cummerata</name>
</user>

</attribute>
2 changes: 1 addition & 1 deletion docs/snippets/advanced-element-header-footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace App\Feeds;

use App\Models\User;
use DragonCode\LaravelFeed\Feeds\Feed;
use Illuminate\Database\Eloquent\Builder;
use App\Models\User;

class HeaderFooterFeed extends Feed
{
Expand Down
9 changes: 7 additions & 2 deletions docs/snippets/advanced-element-header-footer.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<header_footer>

<user>
<id>1</id>
<name>Summer Kuhlman</name>
<name>Prof. Alberta Koch I</name>
</user>
<user>
<id>2</id>
<name>Nicola Wiegand IV</name>
<name>Judy Dietrich IV</name>
</user>

</header_footer>

<g:footer>This is a custom footer element</g:footer>
4 changes: 2 additions & 2 deletions docs/snippets/advanced-element-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace App\Feeds;

use App\Feeds\Info\InfoMethodFeedInfo;
use App\Models\User;
use DragonCode\LaravelFeed\Feeds\Feed;
use DragonCode\LaravelFeed\Feeds\Info\FeedInfo;
use Illuminate\Database\Eloquent\Builder;
use App\Feeds\Info\InfoMethodFeedInfo;
use App\Models\User;

class InfoMethodFeed extends Feed
{
Expand Down
10 changes: 7 additions & 3 deletions docs/snippets/advanced-element-info.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<info_method>

<company>Laravel</company>
<url>https://example.com</url>

<user>
<id>1</id>
<name>Francis Kassulke</name>
<name>Miss Lina Nicolas</name>
</user>
<user>
<id>2</id>
<name>Katarina Morissette II</name>
</user>
<name>Dr. Jack Hagenes MD</name>
</user>

</info_method>
2 changes: 1 addition & 1 deletion docs/snippets/advanced-element-root.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace App\Feeds;

use App\Models\User;
use DragonCode\LaravelFeed\Data\ElementData;
use DragonCode\LaravelFeed\Feeds\Feed;
use Illuminate\Database\Eloquent\Builder;
use App\Models\User;

use function now;

Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/advanced-element-root.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

<user>
<id>1</id>
<name>Prof. Ezra Hoeger</name>
<name>Samantha Wilkinson</name>
</user>
<user>
<id>2</id>
<name>Garth Heathcote</name>
<name>Keyshawn Davis</name>
</user>

</foo>
10 changes: 9 additions & 1 deletion src/Feeds/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

use function class_basename;

abstract class Feed
{
protected FeedFormatEnum $format = FeedFormatEnum::Xml;
Expand Down Expand Up @@ -51,7 +53,13 @@ public function footer(): string

public function root(): ElementData
{
return new ElementData;
return new ElementData(
name: Str::of(static::class)
->classBasename()
->beforeLast(class_basename(self::class))
->snake()
->toString()
);
}

public function info(): FeedInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<model>

<news><id>1</id><title>Some 1</title><content>Some content 1</content><created_at>2025-09-04T04:08:12.000000Z</created_at><updated_at>2025-09-04T04:08:12.000000Z</updated_at></news>
<news><id>2</id><title>Some 2</title><content>Some content 2</content><created_at>2025-09-04T04:08:12.000000Z</created_at><updated_at>2025-09-04T04:08:12.000000Z</updated_at></news>
<news><id>3</id><title>Some 3</title><content>Some content 3</content><created_at>2025-09-04T04:08:12.000000Z</created_at><updated_at>2025-09-04T04:08:12.000000Z</updated_at></news>
<news><id>3</id><title>Some 3</title><content>Some content 3</content><created_at>2025-09-04T04:08:12.000000Z</created_at><updated_at>2025-09-04T04:08:12.000000Z</updated_at></news>

</model>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<model>

<news>
<id>1</id>
<title>Some 1</title>
Expand All @@ -19,4 +21,6 @@
<content>Some content 3</content>
<created_at>2025-09-04T04:08:12.000000Z</created_at>
<updated_at>2025-09-04T04:08:12.000000Z</updated_at>
</news>
</news>

</model>