Files
YNWA Fawzy a7781d9f8a Features:
- SnapDeal added
- Nykaa added
- Tata CLiQ added
- Ajio added

Fixes:
- RSS feed breaks if product has no image
- amazon title wasn't being picked up.

Took 2 hours 45 minutes
2024-10-27 19:09:36 +04:00

44 lines
989 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Feed\Feedable;
use Spatie\Feed\FeedItem;
class RssFeedItem extends Model implements Feedable
{
use HasFactory;
protected $fillable=[
"data"
];
protected function casts(): array
{
return [
'data'=>'json'
];
}
public function toFeedItem(): FeedItem
{
return FeedItem::create([
"id"=>$this->id,
'title' => $this->data["title"],
'summary' => $this->data["summary"],
'updated' => now(),
'link' => route("filament.admin.resources.product-stores.edit" , $this->data["product_id"]),
'image' => Product::find($this->data["product_id"])?->image ?? "",
'authorName' => "Discount Bandit",
]);
}
public static function getFeedItems()
{
return RssFeedItem::all();
}
}