added BillingAlertTriggeredNotification

This commit is contained in:
Čarodej
2022-03-16 10:37:55 +01:00
parent 60407f9dce
commit 9a6abbd6e8
4 changed files with 61 additions and 22 deletions

View File

@@ -13,6 +13,11 @@
size="22"
class="vue-feather text-theme shrink-0"
/>
<alert-triangle-icon
v-if="notification.data.attributes.category === 'billing-alert'"
size="22"
class="vue-feather text-theme shrink-0"
/>
<upload-cloud-icon
v-if="['file-request', 'remote-upload-done'].includes(notification.data.attributes.category)"
size="22"
@@ -74,7 +79,7 @@
</article>
</template>
<script>
import { GiftIcon, CheckIcon, XIcon, MailIcon, UserPlusIcon, UploadCloudIcon, ChevronRightIcon } from 'vue-feather-icons'
import { GiftIcon, CheckIcon, XIcon, MailIcon, UserPlusIcon, UploadCloudIcon, ChevronRightIcon, AlertTriangleIcon } from 'vue-feather-icons'
import MemberAvatar from '../FilesView/MemberAvatar'
import {events} from "../../bus";
@@ -83,6 +88,7 @@ export default {
props: ['notification'],
components: {
MemberAvatar,
AlertTriangleIcon,
ChevronRightIcon,
UploadCloudIcon,
UserPlusIcon,

View File

@@ -1,18 +0,0 @@
<?php
namespace Domain\Notifications\Events;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestUpdate implements ShouldBroadcast
{
public string $test = 'I am tru man';
use Dispatchable;
public function broadcastOn(): PrivateChannel
{
return new PrivateChannel('test.6474ef97-472b-43f3-b607-f71df9d33e43');
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Domain\Subscriptions\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class BillingAlertTriggeredNotification extends Notification implements ShouldQueue
{
use Queueable;
public function via(): array
{
return ['mail', 'database', 'broadcast'];
}
public function toMail(): MailMessage
{
return (new MailMessage)
->subject(__('Your billing alert has been reached!'))
->greeting(__('Hi there'))
->line(__('The billing alert you set previously has been reached. Please go to your user account and revise your spending'))
->action(__('Show Billing'), url('/user/settings/billing'));
}
public function toArray(): array
{
return [
'category' => 'billing-alert',
'title' => 'billing Alert Reached!',
'description' => "The billing alert you set previously has been reached. Please revise your spending.",
'action' => [
'type' => 'route',
'params' => [
'route' => 'Billing',
'button' => 'Show Billing',
],
],
];
}
}

View File

@@ -1,7 +1,10 @@
<?php
namespace Support\Listeners;
use Domain\Subscriptions\Notifications\BillingAlertTriggeredNotification;
use Illuminate\Events\Dispatcher;
use VueFileManager\Subscription\Support\Events\BillingAlertTriggeredEvent;
use VueFileManager\Subscription\Support\Events\SubscriptionWasCreated;
use VueFileManager\Subscription\Support\Events\SubscriptionWasExpired;
use VueFileManager\Subscription\Support\Events\SubscriptionWasUpdated;
@@ -33,15 +36,21 @@ class SubscriptionEventSubscriber
]);
}
public function handleBillingAlertTriggeredEvent($event)
{
$event->alert->user->notify(new BillingAlertTriggeredNotification());
}
/**
* Register the listeners for the subscriber.
*/
public function subscribe(Dispatcher $events): array
{
return [
SubscriptionWasCreated::class => 'handleSubscriptionWasCreated',
SubscriptionWasExpired::class => 'handleSubscriptionWasExpired',
SubscriptionWasUpdated::class => 'handleSubscriptionWasUpdated',
SubscriptionWasCreated::class => 'handleSubscriptionWasCreated',
SubscriptionWasExpired::class => 'handleSubscriptionWasExpired',
SubscriptionWasUpdated::class => 'handleSubscriptionWasUpdated',
BillingAlertTriggeredEvent::class => 'handleBillingAlertTriggeredEvent',
];
}
}