mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
- Added groups, where you can set bunch of items with identified unique keys to get the lowest price on group of products. ( think of it like building your own PC, you add multiple CPUs, and GPUs and the program will notify you when the combination reaches a desired price) - Added 2FA Support to the system (Optional) - Make Sidebar collapsable - Fix name is too short which results to not be saved - Fix a bug where product can be duplicated from amazon stores
68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Group;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class GroupDiscount extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public function __construct(public $group , public $current_price , public $currency){}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function via(object $notifiable): string
|
|
{
|
|
return NtfyChannel::class;
|
|
}
|
|
|
|
public function toNtfy($notifiable)
|
|
{
|
|
$auth=[];
|
|
|
|
if (env("NTFY_USER") && env("NTFY_PASSWORD"))
|
|
$auth["Authorization"] = "Basic " . base64_encode(env("NTFY_USER") .":" . env("NTFY_PASSWORD") );
|
|
elseif (env("NTFY_TOKEN"))
|
|
$auth["Authorization"] = "Bearer " . env("NTFY_TOKEN");
|
|
|
|
|
|
\Http::withHeaders(
|
|
array_merge($auth ,
|
|
[
|
|
"Content-Type"=>"text/markdown",
|
|
'X-Markdown'=>"1",
|
|
'Markdown'=>"1",
|
|
'md'=>"1",
|
|
"Cache: no",
|
|
'Title'=>"Your Group '$this->group' Has Reached the Desired Price. $this->currency $this->current_price ",
|
|
]
|
|
))
|
|
->withBody("Please refer to the website")
|
|
->post(env("NTFY_LINK"));
|
|
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
}
|