Compare commits

...
3 Commits
Author SHA1 Message Date
Joel Male 8f0ae03c4b v5.0.0 2026-01-05 10:56:11 +10:00
Joel Male 428c310525 feat: laravel 12 support 2026-01-05 10:35:36 +10:00
Joel Male f9dcce39b9 chore: support Laravel 10 & 11 2024-01-08 09:26:53 +10:00
4 changed files with 801 additions and 247 deletions
-29
View File
@@ -1,29 +0,0 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('bootstrap/cache')
->exclude('storage')
->exclude('vendor')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
$rules = [
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['operators' => ['=>' => null]],
'linebreak_after_opening_tag' => true,
'ordered_imports' => ['sort_algorithm' => 'length'],
'phpdoc_order' => true,
'phpdoc_no_empty_return' => false,
'yoda_style' => false,
'no_unused_imports' => true,
];
$config = new PhpCsFixer\Config();
return $config->setRules($rules)
->setFinder($finder)
->setUsingCache(false);
+8 -4
View File
@@ -6,7 +6,7 @@
"laravel", "laravel",
"google-shopping-feed" "google-shopping-feed"
], ],
"version": "3.0.0", "version": "5.0.0",
"homepage": "https://github.com/wearepixel/laravel-google-shopping-feed", "homepage": "https://github.com/wearepixel/laravel-google-shopping-feed",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
@@ -19,8 +19,12 @@
"psr-4": { "Wearepixel\\LaravelGoogleShoppingFeed\\" : "src/" } "psr-4": { "Wearepixel\\LaravelGoogleShoppingFeed\\" : "src/" }
}, },
"require": { "require": {
"spatie/array-to-xml": "2.8.*|3.*.*", "php": ">=8.3",
"illuminate/support": "8.*|9.*" "spatie/array-to-xml": "2.8.*|3.*",
"illuminate/support": "10.*|11.*|12.*"
}, },
"prefer-stable": true "prefer-stable": true,
"require-dev": {
"laravel/pint": "^1.26"
}
} }
Generated
+777 -202
View File
File diff suppressed because it is too large Load Diff
+15 -11
View File
@@ -7,24 +7,28 @@
class LaravelGoogleShoppingFeed class LaravelGoogleShoppingFeed
{ {
public $title; public $title;
public $description; public $description;
public $link; public $link;
protected $xml = []; protected $xml = [];
protected $products = []; protected $products = [];
protected $currency = "AUD";
protected $currency = 'AUD';
protected $requiredProductFields = [ protected $requiredProductFields = [
'id', 'id',
'link', 'link',
'title', 'title',
'g:price', 'g:price',
'g:image_link' 'g:image_link',
]; ];
public static function init($title = null, $description = null, $link = null) public static function init($title = null, $description = null, $link = null)
{ {
$feed = new self(); $feed = new self;
$feed->title = $title; $feed->title = $title;
$feed->description = $description; $feed->description = $description;
@@ -62,8 +66,8 @@ public function generate()
'title' => $this->title, 'title' => $this->title,
'description' => $this->description, 'description' => $this->description,
'link' => $this->link, 'link' => $this->link,
] ],
] ],
]; ];
foreach ($this->products as $key => $product) { foreach ($this->products as $key => $product) {
@@ -73,12 +77,12 @@ public function generate()
$xml = ArrayToXml::convert($this->xml, ''); $xml = ArrayToXml::convert($this->xml, '');
$xml = str_replace([' ', '<root>', '</root>', "\n", "\r", '<remove>remove</remove>'], '', $xml); $xml = str_replace([' ', '<root>', '</root>', "\n", "\r", '<remove>remove</remove>'], '', $xml);
$xml = preg_replace([ $xml = preg_replace([
"/item_[0-9][0-9][0-9][0-9]/", '/item_[0-9][0-9][0-9][0-9]/',
"/item_[0-9][0-9][0-9]/", '/item_[0-9][0-9][0-9]/',
"/item_[0-9][0-9]/", '/item_[0-9][0-9]/',
"/item_[0-9]/", '/item_[0-9]/',
], "item", $xml); ], 'item', $xml);
return response($xml)->header('Content-Type', 'text/xml'); return response($xml, 200, ['Content-Type' => 'text/xml']);
} }
} }