added SubscriptionWasCreatedNotification

This commit is contained in:
Čarodej
2022-03-16 11:08:57 +01:00
parent 9a6abbd6e8
commit bc197cbb5e
3 changed files with 57 additions and 1 deletions

View File

@@ -13,6 +13,11 @@
size="22"
class="vue-feather text-theme shrink-0"
/>
<trending-up-icon
v-if="notification.data.attributes.category === 'subscription-created'"
size="22"
class="vue-feather text-theme shrink-0"
/>
<alert-triangle-icon
v-if="notification.data.attributes.category === 'billing-alert'"
size="22"
@@ -79,7 +84,7 @@
</article>
</template>
<script>
import { GiftIcon, CheckIcon, XIcon, MailIcon, UserPlusIcon, UploadCloudIcon, ChevronRightIcon, AlertTriangleIcon } from 'vue-feather-icons'
import { TrendingUpIcon, GiftIcon, CheckIcon, XIcon, MailIcon, UserPlusIcon, UploadCloudIcon, ChevronRightIcon, AlertTriangleIcon } from 'vue-feather-icons'
import MemberAvatar from '../FilesView/MemberAvatar'
import {events} from "../../bus";
@@ -91,6 +96,7 @@ export default {
AlertTriangleIcon,
ChevronRightIcon,
UploadCloudIcon,
TrendingUpIcon,
UserPlusIcon,
CheckIcon,
GiftIcon,

View File

@@ -0,0 +1,47 @@
<?php
namespace Domain\Subscriptions\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
class SubscriptionWasCreatedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
public Subscription $subscription,
) {}
public function via(): array
{
return ['mail', 'database', 'broadcast'];
}
public function toMail(): MailMessage
{
return (new MailMessage)
->subject(__("Your subscription {$this->subscription->plan->name} has been successfully created"))
->greeting(__('Hi there'))
->line(__("You have been successfully subscribed to your {$this->subscription->plan->name} subscription. Now you can take full advantage of our platform."))
->action(__('Go to Subscription'), url('/user/settings/billing'));
}
public function toArray(): array
{
return [
'category' => 'subscription-created',
'title' => 'Subscription Has Been Created',
'description' => "Your subscription {$this->subscription->plan->name} has been successfully created",
'action' => [
'type' => 'route',
'params' => [
'route' => 'Billing',
'button' => 'Show Billing',
],
],
];
}
}

View File

@@ -3,6 +3,7 @@
namespace Support\Listeners;
use Domain\Subscriptions\Notifications\BillingAlertTriggeredNotification;
use Domain\Subscriptions\Notifications\SubscriptionWasCreatedNotification;
use Illuminate\Events\Dispatcher;
use VueFileManager\Subscription\Support\Events\BillingAlertTriggeredEvent;
use VueFileManager\Subscription\Support\Events\SubscriptionWasCreated;
@@ -17,6 +18,8 @@ class SubscriptionEventSubscriber
'max_storage_amount' => $event->subscription->fixedFeature('max_storage_amount'),
'max_team_members' => $event->subscription->fixedFeature('max_team_members'),
]);
$event->subscription->user->notify(new SubscriptionWasCreatedNotification($event->subscription));
}
public function handleSubscriptionWasUpdated($event)