|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Workbench\App\Feeds\Docs; |
| 6 | + |
| 7 | +use DragonCode\LaravelFeed\Data\ElementData; |
| 8 | +use DragonCode\LaravelFeed\Feeds\Feed; |
| 9 | +use DragonCode\LaravelFeed\Feeds\Items\FeedItem; |
| 10 | +use Illuminate\Database\Eloquent\Builder; |
| 11 | +use Illuminate\Database\Eloquent\Model; |
| 12 | +use Workbench\App\Feeds\Docs\Items\ReceiptSitemapFeedItem; |
| 13 | +use Workbench\App\Models\Product; |
| 14 | + |
| 15 | +class ReceiptSitemapFeed extends Feed |
| 16 | +{ |
| 17 | + protected string $name = 'urlset'; |
| 18 | + |
| 19 | + protected array $attributes = [ |
| 20 | + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', |
| 21 | + 'xmlns:xhtml' => 'http://www.w3.org/1999/xhtml', |
| 22 | + 'xmlns:image' => 'http://www.google.com/schemas/sitemap-image/1.1', |
| 23 | + 'xmlns:video' => 'http://www.google.com/schemas/sitemap-video/1.1', |
| 24 | + 'xmlns:news' => 'http://www.google.com/schemas/sitemap-news/0.9', |
| 25 | + ]; |
| 26 | + |
| 27 | + public function builder(): Builder |
| 28 | + { |
| 29 | + return Product::query(); |
| 30 | + } |
| 31 | + |
| 32 | + public function root(): ElementData |
| 33 | + { |
| 34 | + return new ElementData( |
| 35 | + name : $this->name, |
| 36 | + attributes: $this->attributes, |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + public function item(Model $model): FeedItem |
| 41 | + { |
| 42 | + return new ReceiptSitemapFeedItem($model); |
| 43 | + } |
| 44 | + |
| 45 | + public function filename(): string |
| 46 | + { |
| 47 | + return '../../../../../../../../../docs/snippets/receipt-sitemap-feed.xml'; |
| 48 | + } |
| 49 | +} |
0 commit comments