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
20 changes: 10 additions & 10 deletions docs/snippets/advanced-directive-array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
<array_directive>

<user>
<name>Ms. Kassandra Brakus</name>
<avatar>https://via.placeholder.com/640x480.png/00ddcc?text=accusamus</avatar>
<avatar>https://via.placeholder.com/640x480.png/0099aa?text=atque</avatar>
<images name="quia nisi deleniti">https://via.placeholder.com/640x480.png/003399?text=excepturi</images>
<images name="sit et vero">https://via.placeholder.com/640x480.png/00aacc?text=autem</images>
<name>Dr. Albert Gaylord PhD</name>
<avatar>https://via.placeholder.com/640x480.png/0033bb?text=repellendus</avatar>
<avatar>https://via.placeholder.com/640x480.png/0055cc?text=vel</avatar>
<images name="reiciendis non rerum">https://via.placeholder.com/640x480.png/00aaff?text=facere</images>
<images name="nihil ipsam culpa">https://via.placeholder.com/640x480.png/006633?text=rerum</images>
</user>
<user>
<name>Jermain Gulgowski</name>
<avatar>https://via.placeholder.com/640x480.png/0055cc?text=qui</avatar>
<avatar>https://via.placeholder.com/640x480.png/008877?text=aut</avatar>
<images name="iure dignissimos repellat">https://via.placeholder.com/640x480.png/00ee66?text=sint</images>
<images name="unde veritatis a">https://via.placeholder.com/640x480.png/003333?text=quaerat</images>
<name>Lia Jerde</name>
<avatar>https://via.placeholder.com/640x480.png/00cc55?text=cupiditate</avatar>
<avatar>https://via.placeholder.com/640x480.png/0055dd?text=ut</avatar>
<images name="voluptatem numquam placeat">https://via.placeholder.com/640x480.png/006633?text=nobis</images>
<images name="sed reprehenderit molestiae">https://via.placeholder.com/640x480.png/007733?text=dolor</images>
</user>

</array_directive>
5 changes: 0 additions & 5 deletions docs/snippets/advanced-directive-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ public function item(Model $model): FeedItem
{
return new AttributesDirectiveFeedItem($model);
}

public function filename(): string
{
return '../../../../../../../../../docs/snippets/advanced-directive-attributes.xml';
}
}
10 changes: 5 additions & 5 deletions docs/snippets/advanced-directive-attributes.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<attributes_directive>

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

<user>
<name>Rachelle Stokes</name>
<contact email="ryann.mraz@example.net" phone="555-000-1"/>
<name>Emile Kling</name>
<contact email="alangworth@example.com" phone="555-000-1"/>
</user>
<user>
<name>Dr. Chelsie Schroeder Jr.</name>
<contact email="dee36@example.org" phone="555-000-2"/>
<name>Miss Kamille Stracke DDS</name>
<contact email="hahn.adele@example.com" phone="555-000-2"/>
</user>

</attributes_directive>
8 changes: 4 additions & 4 deletions docs/snippets/advanced-directive-cdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<cdata_directive>

<user>
<name><![CDATA[<h1>Jasper Cassin PhD</h1>]]></name>
<email>rasheed17@example.net</email>
<name><![CDATA[<h1>Mortimer Hermiston</h1>]]></name>
<email>lura20@example.net</email>
</user>
<user>
<name><![CDATA[<h1>Jeffrey Kilback DVM</h1>]]></name>
<email>sienna75@example.net</email>
<name><![CDATA[<h1>Esta Bins</h1>]]></name>
<email>alessia.bins@example.net</email>
</user>

</cdata_directive>
8 changes: 4 additions & 4 deletions docs/snippets/advanced-directive-mixed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<mixed_directive>

<user>
<name>Israel Shanahan</name>
<name>Dr. Adrien Price DDS</name>
<some>
<first>Foo</first>
<second>estefania92@example.org</second>
<second>alessandra73@example.com</second>
</some>
</user>
<user>
<name>Dewitt Kessler DDS</name>
<name>Dr. Randall Weber</name>
<some>
<first>Foo</first>
<second>xfisher@example.com</second>
<second>cristian08@example.org</second>
</some>
</user>

Expand Down
8 changes: 4 additions & 4 deletions docs/snippets/advanced-directive-value.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<value_directive>

<user>
<name>Icie Crooks</name>
<contact type="email">langosh.okey@example.org</contact>
<name>Linnie Kuhn</name>
<contact type="email">russel.ledner@example.org</contact>
</user>
<user>
<name>Dr. Reta Langosh IV</name>
<contact type="email">cecilia35@example.com</contact>
<name>Enos Torphy Sr.</name>
<contact type="email">sonya44@example.com</contact>
</user>

</value_directive>
5 changes: 0 additions & 5 deletions docs/snippets/advanced-element-attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@ public function item(Model $model): FeedItem
{
return new AttributeFeedItem($model);
}

public function filename(): string
{
return '../../../../../../../../../docs/snippets/advanced-element-attribute.xml';
}
}
8 changes: 4 additions & 4 deletions docs/snippets/advanced-element-attribute.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<attribute>

<user created_at="2025-09-04 20:36:43">
<user created_at="2025-09-05 00:17:10">
<id>1</id>
<name>Eriberto Lind</name>
<name>Ara Littel</name>
</user>
<user created_at="2025-09-04 20:36:43">
<user created_at="2025-09-05 00:17:10">
<id>2</id>
<name>Mr. Michael Reilly</name>
<name>Sylvia Rippin</name>
</user>

</attribute>
5 changes: 0 additions & 5 deletions docs/snippets/advanced-element-header-footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ public function footer(): string
{
return "\n<g:footer>This is a custom footer element</g:footer>";
}

public function filename(): string
{
return '../../../../../../../../../docs/snippets/advanced-element-header-footer.xml';
}
}
4 changes: 2 additions & 2 deletions docs/snippets/advanced-element-header-footer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

<user>
<id>1</id>
<name>Prof. Joe Hills</name>
<name>Brayan Schaefer</name>
</user>
<user>
<id>2</id>
<name>Alyson Hoppe</name>
<name>Jedidiah Mayer</name>
</user>

</header_footer>
Expand Down
5 changes: 0 additions & 5 deletions docs/snippets/advanced-element-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@ public function info(): FeedInfo
{
return new InfoMethodFeedInfo;
}

public function filename(): string
{
return '../../../../../../../../../docs/snippets/advanced-element-info.xml';
}
}
4 changes: 2 additions & 2 deletions docs/snippets/advanced-element-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<user>
<id>1</id>
<name>Millie Predovic</name>
<name>Dr. Aurelio Hermann DDS</name>
</user>
<user>
<id>2</id>
<name>Dominic Mitchell Sr.</name>
<name>Gardner Farrell</name>
</user>

</info_method>
5 changes: 0 additions & 5 deletions docs/snippets/advanced-element-root.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ public function root(): ElementData
]
);
}

public function filename(): string
{
return '../../../../../../../../../docs/snippets/advanced-element-root.xml';
}
}
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>Merle Kulas</name>
<name>Emilie Rosenbaum</name>
</user>
<user>
<id>2</id>
<name>Prof. Tristin Hahn Jr.</name>
<name>Gail Lindgren</name>
</user>

</foo>
53 changes: 41 additions & 12 deletions docs/snippets/receipt-instagram-feed-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace App\Feeds\Items;

use DragonCode\LaravelFeed\Feeds\Items\FeedItem;
use Illuminate\Support\Arr;

use function route;
use function collect;
use function fake;

/** @property-read \App\Models\Product $model */
class InstagramFeedItem extends FeedItem
Expand All @@ -19,21 +21,48 @@ public function name(): string
public function toArray(): array
{
return [
'g:id' => $this->model->id,
'g:title' => $this->model->title,
'g:id' => $this->model->id,

'g:description' => [
'@cdata' => $this->model->description,
],

'g:brand' => $this->model->brand,
'g:title' => ['@cdata' => $this->model->title],
'g:description' => ['@cdata' => $this->model->description],

'g:link' => route('products.show', $this->model->slug),
'g:image_link' => $this->model->image,
'g:image_link' => $this->firstImage(),

'@g:additional_image_link' => $this->images(),

'g:brand' => $this->model->brand,
'g:condition' => 'new',
'g:availability' => 'in stock',

'g:price' => $this->model->price,
'g:sale_price' => $this->model->price,

'g:item_group_id' => 12345,

'g:status' => 'active',

'g:color' => ['@cdata' => fake()->colorName()],

'g:size' => fake()->numberBetween(10, 50),

'g:availability' => $this->model->quantity ? 'in stock' : 'out of stock',
'g:status' => $this->model->quantity ? 'active' : 'inactive',
'g:price' => $this->model->price,
'g:age_group' => 'adult',

'g:material' => ['@cdata' => fake()->word()],
'g:pattern' => ['@cdata' => 'regular'],

'g:google_product_category' => 1000,
'g:fb_product_category' => 2000,
];
}

protected function firstImage(): string
{
return Arr::first($this->model->images);
}

protected function images(): array
{
return collect($this->model->images)->skip(1)->all();
}
}
17 changes: 11 additions & 6 deletions docs/snippets/receipt-instagram-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@

namespace App\Feeds;

use App\Feeds\Items\InstagramFeedItem;
use App\Models\Product;
use DragonCode\LaravelFeed\Data\ElementData;
use DragonCode\LaravelFeed\Feeds\Feed;
use DragonCode\LaravelFeed\Feeds\Items\FeedItem;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

use function config;

class InstagramFeed extends Feed
{
public function builder(): Builder
{
return Product::query();
}

public function root(): ElementData
{
return new ElementData('offers');
}

public function header(): string
{
$name = config('app.name');
Expand All @@ -38,13 +43,13 @@ public function footer(): string
return "\n</channel>\n</rss>";
}

public function filename(): string
public function item(Model $model): FeedItem
{
return 'instagram.xml';
return new InstagramFeedItem($model);
}

public function item(Model $model): FeedItem
public function filename(): string
{
return new Items\InstagramFeedItem($model);
return 'instagram.xml';
}
}
57 changes: 57 additions & 0 deletions docs/snippets/receipt-instagram-feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Laravel</title>
<link>https://example.com</link>
<offers>

<item>
<g:id>1</g:id>
<g:title><![CDATA[nobis minus qui asperiores]]></g:title>
<g:description><![CDATA[Iusto quis ut id ea quis. Odit qui est quas sunt aut. Eaque quia nam reprehenderit voluptatem aut nostrum eos.]]></g:description>
<g:link>https://example.com/products/quaerat-voluptatem-consequuntur-cumque-aut-sit-dolorem</g:link>
<g:image_link>https://via.placeholder.com/640x480.png/00ff22?text=esse</g:image_link>
<g:additional_image_link>https://via.placeholder.com/640x480.png/007788?text=ea</g:additional_image_link>
<g:additional_image_link>https://via.placeholder.com/640x480.png/006644?text=eveniet</g:additional_image_link>
<g:brand>explicabo</g:brand>
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price>527</g:price>
<g:sale_price>527</g:sale_price>
<g:item_group_id>12345</g:item_group_id>
<g:status>active</g:status>
<g:color><![CDATA[Thistle]]></g:color>
<g:size>45</g:size>
<g:age_group>adult</g:age_group>
<g:material><![CDATA[eveniet]]></g:material>
<g:pattern><![CDATA[regular]]></g:pattern>
<g:google_product_category>1000</g:google_product_category>
<g:fb_product_category>2000</g:fb_product_category>
</item>
<item>
<g:id>2</g:id>
<g:title><![CDATA[sed facere incidunt et]]></g:title>
<g:description><![CDATA[Ipsa repudiandae in quo suscipit atque dolor ipsam. Dolorem pariatur id deserunt voluptatem ea. Ut eligendi officiis at sequi molestias enim sed.]]></g:description>
<g:link>https://example.com/products/et-non-neque-molestias-in</g:link>
<g:image_link>https://via.placeholder.com/640x480.png/00ffee?text=totam</g:image_link>
<g:additional_image_link>https://via.placeholder.com/640x480.png/0044ff?text=voluptatem</g:additional_image_link>
<g:additional_image_link>https://via.placeholder.com/640x480.png/00aabb?text=expedita</g:additional_image_link>
<g:brand>quis</g:brand>
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price>864</g:price>
<g:sale_price>864</g:sale_price>
<g:item_group_id>12345</g:item_group_id>
<g:status>active</g:status>
<g:color><![CDATA[DarkViolet]]></g:color>
<g:size>29</g:size>
<g:age_group>adult</g:age_group>
<g:material><![CDATA[voluptas]]></g:material>
<g:pattern><![CDATA[regular]]></g:pattern>
<g:google_product_category>1000</g:google_product_category>
<g:fb_product_category>2000</g:fb_product_category>
</item>

</offers>

</channel>
</rss>
Loading