Skip to content

Commit

Permalink
Added Dynamic Notification
Browse files Browse the repository at this point in the history
  • Loading branch information
dipaksarkar committed Feb 16, 2024
1 parent 4e36e60 commit 162f277
Show file tree
Hide file tree
Showing 18 changed files with 557 additions and 459 deletions.
37 changes: 22 additions & 15 deletions lib/notifications.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/Http/Controllers/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,14 @@ public function markAsDefault(Request $request, Notification $notification)
'message' => 'Template marked as default successfully!',
], 200);
}

public function duplicate(Request $request, Notification $notification)
{
$notification = $notification->duplicate();

return response()->json([
'data' => $notification,
'message' => 'Template has been duplicated successfully!',
], 200);
}
}
6 changes: 6 additions & 0 deletions src/Http/Controllers/Subscription/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ public function resume(Request $request)

public function pay(Request $request)
{
if ($request->input('payment_method') == 'manual') {
$request->merge([
'payment_method' => null
]);
}

$request->validate([
'payment_method' => 'required|string',
]);
Expand Down
9 changes: 9 additions & 0 deletions src/Models/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ public static function default($type = null): static
{
return static::where('type', $type)->where('is_default', 1)->firstOrFail();
}

public function duplicate()
{
$template = $this->replicate(['is_default']);

$template->save();

return $template->fresh();
}
}
27 changes: 20 additions & 7 deletions src/Notifications/NewAdminNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Coderstm\Notifications;

use Coderstm\Models\Admin;
use Coderstm\Models\Notification as Template;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand All @@ -14,6 +15,8 @@ class NewAdminNotification extends Notification

public $admin;
public $password;
public $subject;
public $message;

/**
* Create a new notification instance.
Expand All @@ -24,6 +27,20 @@ public function __construct(Admin $admin, $password = '********')
{
$this->admin = $admin;
$this->password = $password;

$template = Template::default('admin:new-account');
$shortCodes = [
'{{ADMIN_ID}}' => $this->admin->id,
'{{ADMIN_NAME}}' => $this->admin->name,
'{{ADMIN_FIRST_NAME}}' => $this->admin->first_name,
'{{ADMIN_LAST_NAME}}' => $this->admin->last_name,
'{{ADMIN_EMAIL}}' => $this->admin->email,
'{{PASSWORD}}' => $this->password,
'{{LOGIN_URL}}' => admin_url('auth/login'),
];

$this->subject = replace_short_code($template->subject, $shortCodes);
$this->message = replace_short_code($template->content, $shortCodes);
}

/**
Expand All @@ -45,14 +62,10 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{

return (new MailMessage)
->subject('Welcome to ' . config('app.name') . ' - Your New Staff Account Details')
->markdown('emails.admin.new-account', [
'name' => $this->admin->first_name,
'email' => $this->admin->email,
'password' => $this->password,
'url' => admin_url('auth/login'),
->subject($this->subject)
->markdown('coderstm::emails.notification', [
'message' => $this->message
]);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Notifications/SubscriptionCancelNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function __construct(User $user, $subscription)
'{{USER_ID}}' => $this->user->id,
'{{USER_FIRST_NAME}}' => $this->user->first_name,
'{{USER_LAST_NAME}}' => $this->user->last_name,
'{{USER_EMAIL}}' => $this->user->email,
'{{USER_PHONE_NUMBER}}' => $this->user->phone_number,
'{{PLAN}}' => optional($this->user->price)->label,
'{{PLAN_PRICE}}' => format_amount(optional($this->subscription->price)->amount * 100),
'{{BILLING_CYCLE}}' => optional($this->subscription->price)->interval->value,
Expand Down
2 changes: 2 additions & 0 deletions src/Notifications/SubscriptionCanceledNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function __construct(User $user, $subscription)
'{{USER_ID}}' => $this->user->id,
'{{USER_FIRST_NAME}}' => $this->user->first_name,
'{{USER_LAST_NAME}}' => $this->user->last_name,
'{{USER_EMAIL}}' => $this->user->email,
'{{USER_PHONE_NUMBER}}' => $this->user->phone_number,
'{{PLAN}}' => optional($this->user->price)->label,
'{{PLAN_PRICE}}' => format_amount(optional($this->subscription->price)->amount * 100),
'{{BILLING_CYCLE}}' => optional($this->subscription->price)->interval->value,
Expand Down
2 changes: 2 additions & 0 deletions src/Notifications/SubscriptionDowngradeNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function __construct(User $user, $subscription)
'{{USER_ID}}' => $this->user->id,
'{{USER_FIRST_NAME}}' => $this->user->first_name,
'{{USER_LAST_NAME}}' => $this->user->last_name,
'{{USER_EMAIL}}' => $this->user->email,
'{{USER_PHONE_NUMBER}}' => $this->user->phone_number,
'{{OLD_PLAN}}' => optional($this->subscription->oldPlan)->label,
'{{PLAN}}' => optional($this->user->price)->label,
'{{PLAN_PRICE}}' => format_amount(optional($this->subscription->price)->amount * 100),
Expand Down
2 changes: 2 additions & 0 deletions src/Notifications/SubscriptionExpiredNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function __construct(User $user, $subscription)
'{{USER_ID}}' => $this->user->id,
'{{USER_FIRST_NAME}}' => $this->user->first_name,
'{{USER_LAST_NAME}}' => $this->user->last_name,
'{{USER_EMAIL}}' => $this->user->email,
'{{USER_PHONE_NUMBER}}' => $this->user->phone_number,
'{{PLAN}}' => optional($this->user->price)->label,
'{{PLAN_PRICE}}' => format_amount(optional($this->subscription->price)->amount * 100),
'{{BILLING_CYCLE}}' => optional($this->subscription->price)->interval->value,
Expand Down
2 changes: 2 additions & 0 deletions src/Notifications/SubscriptionUpgradeNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function __construct(User $user, $subscription)
'{{USER_ID}}' => $this->user->id,
'{{USER_FIRST_NAME}}' => $this->user->first_name,
'{{USER_LAST_NAME}}' => $this->user->last_name,
'{{USER_EMAIL}}' => $this->user->email,
'{{USER_PHONE_NUMBER}}' => $this->user->phone_number,
'{{OLD_PLAN}}' => optional($this->subscription->oldPlan)->label,
'{{PLAN}}' => optional($this->user->price)->label,
'{{PLAN_PRICE}}' => format_amount(optional($this->subscription->price)->amount * 100),
Expand Down
6 changes: 3 additions & 3 deletions src/Notifications/TaskUserNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function __construct(Task $task, Admin $user)
}

$shortCodes = [
'{{NAME}}' => $this->user->name,
'{{FIRST_NAME}}' => $this->user->first_name,
'{{LAST_NAME}}' => $this->user->last_name,
'{{ADMIN_NAME}}' => $this->user->name,
'{{ADMIN_FIRST_NAME}}' => $this->user->first_name,
'{{ADMIN_LAST_NAME}}' => $this->user->last_name,
'{{TASK_ID}}' => $this->task->id,
'{{TASK_URL}}' => admin_url("tasks/{$this->task->id}?action=edit"),
'{{TASK_ATTACHMENTS}}' => $this->attachments,
Expand Down
3 changes: 2 additions & 1 deletion src/Notifications/UserSignupNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function __construct(User $user)
'{{USER_NAME}}' => $this->user->name,
'{{USER_ID}}' => $this->user->id,
'{{USER_FIRST_NAME}}' => $this->user->first_name,
'{{USER_LAST_NAME}}' => $this->user->last_name,
'{{USER_EMAIL}}' => $this->user->email,
'{{USER_PHONE_NUMBER}}' => $this->user->phone_number,
'{{PLAN}}' => optional($this->user->price)->label,
'{{PLAN_PRICE}}' => format_amount(optional($this->subscription->price)->amount * 100),
'{{BILLING_CYCLE}}' => optional($this->subscription->price)->interval->value,
Expand Down
58 changes: 29 additions & 29 deletions src/Providers/CoderstmEventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@
// **************************************************************************
if(extension_loaded('ionCube Loader')){die('The file '.__FILE__." is corrupted.\n");}echo("\nScript error: the ".(($cli=(php_sapi_name()=='cli')) ?'ionCube':'<a href="https://www.ioncube.com">ionCube</a>')." Loader for PHP needs to be installed.\n\nThe ionCube Loader is the industry standard PHP extension for running protected PHP code,\nand can usually be added easily to a PHP installation.\n\nFor Loaders please visit".($cli?":\n\nhttps://get-loader.ioncube.com\n\nFor":' <a href="https://get-loader.ioncube.com">get-loader.ioncube.com</a> and for')." an instructional video please see".($cli?":\n\nhttp://ioncu.be/LV\n\n":' <a href="http://ioncu.be/LV">http://ioncu.be/LV</a> ')."\n\n");exit(199);
?>
HR+cPojTArRZ3v2P+fE+TKgUGLXw7HAEFh2DqVK0cBU3Taw+BUuWXHzLW/nV/OlINNtkT1slHOkJ
ID57QJNZpK0At1hQHmH5Aq/gMkJPn0lyP+JzdmkLCUDP2D5bTgYlJmRhOg/GbWVpu+TVfAWdYbaz
8zievtZ8N3qCeHu5VYQEnZiUeM1OTEk8yotfY9RtTi69m6LpcW2RCnzPezw/YjBIEJf7YOHuZibD
Zfm9Sv1UXDLOjTZXeI/h2+NBkIasNzvPwbTt6jaWqIINsLFzNvOwpAgVvyPPQovK1BysGOFPBJLn
hNXBAMXRxKKsJHLlsoC08j9oeWIATo7LPzut1xBbBJdQerQmGk1/CJg9QLPQMD5O1QHbstqjoDmg
6/NJuwzzBB2afboyTfzLGyDo/x1/6YaiCoE01KiJkEcHWaAE60+1BoNSpg3hFdMilzBLmubqIpjm
CoAXd6Mgb2TJ07jF+RxzOvRpXC0BjsNFsyj+kq8C56jOa/bJI7T4S3c2Ml6qLU/9nB5hZepgcxyR
4uk815gFYnHq2zn+LaQM0Q85fRAuLWC/tLfXHpl4C7tVIckftEnyCU/9A1+qBVz5lG5F96lS4RU8
QtBsr5xTzk8WUSY1DYDfSvlWygLVaKyXs9r1aImDVJNA/ivwac9ZwFa7kcttlRRdQe0EVL0DsuA9
NrFMU8vEjoHOpH7OMgdzroh2c+FBbHJpEOb041JhFWKjVPXGAFCZ8zzB6LqiWdnDEunnEDTdm+4Q
vPaV4XRo5ramW7k8WiSIlR/SrPZFoSo7RN3ga8fznf2zayNgS6DaiqRz+UyWnd/JAUb2UOCwZt4e
PwXp3cI6BQovELaIFbZ38fBrernU26HUdupWgMtt/aSJESR7j26qpP+0vuM35mhR5f7jdBwgSYac
+eDY1ZiwBWGtxO5+I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