Files
pricebuddy/app/Notifications/AddUrlFailedNotification.php
Jeremy Graham 618cf9ab5b feat: add multiple URLs to a product at once, in the UI and the API (#206)
The product page has a new "Add multiple URLs" action that takes up to 50
URLs, one per line. POST /api/products/{id}/urls does the same for API
clients and needs the product:update ability. Invalid, repeated and existing
URLs are skipped and reported. Each other URL is scraped by a queued job,
because one scrape can take up to 30 seconds. A URL that cannot be added sends
a "URL not added" notification.
2026-10-06 16:50:11 +11:00

45 lines
1.2 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\Product;
use Filament\Notifications\Actions\Action;
use Filament\Notifications\Notification as DatabaseNotification;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;
class AddUrlFailedNotification extends Notification
{
use Queueable;
public function __construct(public Product $product, public string $url) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function toArray(object $notifiable): array
{
return [
'product_id' => $this->product->getKey(),
'url' => $this->url,
];
}
public function toDatabase($notifiable): array
{
return DatabaseNotification::make()
->title('Unable to add URL to '.Str::limit($this->product->title, 60))
->body(Str::limit($this->url, 200).' has no price, or no store matches it.')
->status('warning')
->actions([
Action::make('view')
->url(parse_url($this->product->view_url, PHP_URL_PATH))
->label('View product'),
])
->getDatabaseMessage();
}
}