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
2 changes: 2 additions & 0 deletions docs/laravel-feeds.tree
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
<toc-element topic="directives.topic" />
<toc-element topic="eloquent.topic" />
<toc-element topic="location.topic" />
<toc-element topic="presets.topic" />
<toc-element topic="events.topic" />
</toc-element>
<toc-element toc-title="Receipts">
<toc-element topic="receipt-sitemap.topic" />
<toc-element topic="receipt-instagram.topic" />
<toc-element topic="receipt-yandex.topic" />
<toc-element topic="receipt-rss-atom.topic" />
</toc-element>
</instance-profile>
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. Thelma Johnston PhD</name>
<avatar>https://via.placeholder.com/640x480.png/00cc00?text=distinctio</avatar>
<avatar>https://via.placeholder.com/640x480.png/006655?text=eum</avatar>
<images name="ut tempora eum">https://via.placeholder.com/640x480.png/0033bb?text=quasi</images>
<images name="dolorum repudiandae ut">https://via.placeholder.com/640x480.png/003333?text=iure</images>
<name>Noemy Kulas</name>
<avatar>https://via.placeholder.com/640x480.png/00ccff?text=minus</avatar>
<avatar>https://via.placeholder.com/640x480.png/00cc66?text=unde</avatar>
<images name="blanditiis in qui">https://via.placeholder.com/640x480.png/00cc99?text=minus</images>
<images name="sunt odit dolores">https://via.placeholder.com/640x480.png/00aaee?text=enim</images>
</user>
<user>
<name>Dr. Billy McLaughlin Sr.</name>
<avatar>https://via.placeholder.com/640x480.png/006688?text=autem</avatar>
<avatar>https://via.placeholder.com/640x480.png/00aa66?text=commodi</avatar>
<images name="dolorem voluptatem sint">https://via.placeholder.com/640x480.png/001199?text=voluptas</images>
<images name="temporibus nisi placeat">https://via.placeholder.com/640x480.png/0022cc?text=hic</images>
<name>Mr. Orlando Langworth IV</name>
<avatar>https://via.placeholder.com/640x480.png/0099aa?text=ea</avatar>
<avatar>https://via.placeholder.com/640x480.png/000088?text=occaecati</avatar>
<images name="vel temporibus maxime">https://via.placeholder.com/640x480.png/009955?text=est</images>
<images name="aut nihil voluptatem">https://via.placeholder.com/640x480.png/007788?text=voluptatum</images>
</user>

</array_directive>
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="1977"/>
<company since="1983"/>
<url>https://example.com</url>

<user>
<name>Dr. Rudolph Labadie</name>
<contact email="runolfsdottir.guadalupe@example.com" phone="555-000-1"/>
<name>Kali Schamberger</name>
<contact email="hardy.spinka@example.org" phone="555-000-1"/>
</user>
<user>
<name>Dr. Adam Turcotte MD</name>
<contact email="veffertz@example.org" phone="555-000-2"/>
<name>Kathleen Lynch</name>
<contact email="rossie65@example.net" 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>Kareem Gusikowski</h1>]]></name>
<email>ross.mcdermott@example.net</email>
<name><![CDATA[<h1>Cheyanne Labadie MD</h1>]]></name>
<email>jovani.torphy@example.net</email>
</user>
<user>
<name><![CDATA[<h1>Jaunita Wilderman</h1>]]></name>
<email>reichert.elwyn@example.org</email>
<name><![CDATA[<h1>Dock Cruickshank</h1>]]></name>
<email>rhowell@example.com</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>Shirley Hegmann</name>
<name>Prof. Ed Hegmann Sr.</name>
<some>
<first>Foo</first>
<second>margarett18@example.com</second>
<second>gerlach.prince@example.com</second>
</some>
</user>
<user>
<name>Gabriel Olson</name>
<name>Dr. Torrance Kris</name>
<some>
<first>Foo</first>
<second>ladarius24@example.net</second>
<second>hreichel@example.net</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>Mrs. Rosamond Lehner</name>
<contact type="email">kiara55@example.org</contact>
<name>Margaret Gottlieb</name>
<contact type="email">ferry.delilah@example.org</contact>
</user>
<user>
<name>Rosalia Donnelly</name>
<contact type="email">luella39@example.com</contact>
<name>Prof. Itzel Auer</name>
<contact type="email">myra00@example.com</contact>
</user>

</value_directive>
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-14T17:45:16+00:00">
<user created_at="2025-09-14T20:47:53+00:00">
<id>1</id>
<name>Aaliyah Rowe</name>
<name>Jaron Conn</name>
</user>
<user created_at="2025-09-14T17:45:16+00:00">
<user created_at="2025-09-14T20:47:53+00:00">
<id>2</id>
<name>Valentine Mosciski DVM</name>
<name>Eloisa West</name>
</user>

</attribute>
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. Dandre Altenwerth III</name>
<name>Stanford Leffler</name>
</user>
<user>
<id>2</id>
<name>Miss Lesly Dicki</name>
<name>Ellen Johns</name>
</user>

</header_footer>
Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/advanced-element-info-before-false.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<user>
<id>1</id>
<name>Misty Hahn IV</name>
<name>Miss Corrine Wehner</name>
</user>
<user>
<id>2</id>
<name>Kaya Zieme</name>
<name>Prof. Annamae Gibson III</name>
</user>

</info_method>
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>Darwin McKenzie</name>
<name>Prof. Glennie Hessel V</name>
</user>
<user>
<id>2</id>
<name>Emory Torp</name>
<name>Odie Christiansen</name>
</user>

</info_method>
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>Whitney Barton</name>
<name>Dr. Laron Ziemann DDS</name>
</user>
<user>
<id>2</id>
<name>Prof. Ron Cormier PhD</name>
<name>Elton Stark</name>
</user>

</foo>
13 changes: 13 additions & 0 deletions docs/snippets/presets-all.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use DragonCode\LaravelFeed\Presets\InstagramFeedPreset;
use DragonCode\LaravelFeed\Presets\RssFeedPreset;
use DragonCode\LaravelFeed\Presets\SitemapFeedPreset;
use DragonCode\LaravelFeed\Presets\YandexFeedPreset;

class ProductFeed extends InstagramFeedPreset {}
class ProductFeed extends YandexFeedPreset {}
class ProductFeed extends SitemapFeedPreset {}
class ProductFeed extends RssFeedPreset {}
68 changes: 0 additions & 68 deletions docs/snippets/receipt-instagram-feed-item.php

This file was deleted.

60 changes: 31 additions & 29 deletions docs/snippets/receipt-instagram-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,50 @@

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 DragonCode\LaravelFeed\Presets\InstagramFeedPreset;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

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

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

public function header(): string
{
$name = config('app.name');
$url = config('app.url');

return <<<XML
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>$name</title>
<link>$url</link>

XML;
}

public function footer(): string
{
return "\n</channel>\n</rss>";
}

public function item(Model $model): FeedItem
{
return new InstagramFeedItem($model);
return parent::item($model)
->title($model->title)
->description($model->description)
->brand($model->brand) // By default, null
->url($model->url)
->price(price: $model->price, salePrice: $model->price) // By default, salePrice = price
->image($model->images[0])
->images($model->images) // By default, null
->availability($model->quantity > 0 ? 'in stock' : 'out of stock') // By default, 'in stock'
->status($model->quantity > 0 ? 'active' : 'inactive') // By default, 'active'
->condition('new') // By default, 'new'
->group(12345) // By default, null
->googleCategory(123) // By default, null
->facebookCategory(456) // By default, null
->additional([
'g:foo' => 'Some foo',
'g:bar' => 'Some bar',

'g:baz' => [
'@attributes' => ['qwe' => 'rty'],
'@value' => 'Some baz',
],

'@g:arrayable' => [
'a',
'b',
'c',
],
]);
}

public function filename(): string
Expand Down
Loading