- email template

This commit is contained in:
Peter Papp
2021-03-23 06:47:28 +01:00
parent 021e78e0c5
commit 0d4b8403ba
3 changed files with 34 additions and 19 deletions
+15 -10
View File
@@ -7,6 +7,7 @@ use App\Http\Resources\UserResource;
use App\Models\User; use App\Models\User;
use App\Notifications\Oasis\PaymentRequiredNotification; use App\Notifications\Oasis\PaymentRequiredNotification;
use App\Services\Oasis\CzechRegisterSearchService; use App\Services\Oasis\CzechRegisterSearchService;
use App\Services\StripeService;
use Hash; use Hash;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Contracts\Routing\ResponseFactory;
@@ -55,15 +56,15 @@ class AdminController extends Controller
$newbie $newbie
->settings() ->settings()
->create([ ->create([
'ico' => $request->ico, 'ico' => $request->ico,
'name' => $request->name, 'name' => $request->name,
'address' => $request->address, 'address' => $request->address,
'state' => $request->state, 'state' => $request->state,
'city' => $request->city, 'city' => $request->city,
'postal_code' => $request->postal_code, 'postal_code' => $request->postal_code,
'country' => $request->country, 'country' => $request->country,
'phone_number' => $request->phone_number, 'phone_number' => $request->phone_number,
'timezone' => '1.0', 'timezone' => '1.0',
]); ]);
// Store subscription request // Store subscription request
@@ -73,9 +74,13 @@ class AdminController extends Controller
'requested_plan' => $request->plan, 'requested_plan' => $request->plan,
]); ]);
$plan = resolve(StripeService::class)
->getPlan($request->plan);
// Send notification with payment details // Send notification with payment details
$newbie->notify(new PaymentRequiredNotification( $newbie->notify(new PaymentRequiredNotification(
$newbie->subscriptionRequest $newbie->subscriptionRequest,
$plan
)); ));
return response( return response(
+3 -1
View File
@@ -17,7 +17,9 @@ class PlanResource extends JsonResource
public function toArray($request) public function toArray($request)
{ {
// Get subscribers // Get subscribers
$subscriber_count = Subscription::where('stripe_plan', $this['plan']['id'])->where('stripe_status', 'active')->get(); $subscriber_count = Subscription::where('stripe_plan', $this['plan']['id'])
->where('stripe_status', 'active')
->get();
return [ return [
'data' => [ 'data' => [
@@ -6,6 +6,7 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use Laravel\Cashier\Cashier;
class PaymentRequiredNotification extends Notification class PaymentRequiredNotification extends Notification
{ {
@@ -15,16 +16,18 @@ class PaymentRequiredNotification extends Notification
* Create a new notification instance. * Create a new notification instance.
* *
* @param $order * @param $order
* @param $plan
*/ */
public function __construct($order) public function __construct($order, $plan)
{ {
$this->order = $order; $this->order = $order;
$this->plan = $plan;
} }
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable * @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via($notifiable)
@@ -35,24 +38,29 @@ class PaymentRequiredNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable * @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail($notifiable)
{ {
$url = url("/platba/{$this->order['id']}"); $url = url("/platba/{$this->order['id']}");
$price = Cashier::formatAmount($this->plan['plan']['amount']);
$storage = format_gigabytes($this->plan['product']['metadata']['capacity']);
return (new MailMessage) return (new MailMessage)
->subject('🏝 Platobne instrukcie pre zakupenie balicka a aktivaciu Vasho konta') ->subject('🏝 Potvrzeni Objednavky - OasisDrive')
->line('🏝 Platobne instrukcie pre zakupenie balicka a aktivaciu Vasho konta') ->greeting('Dobry den')
->action('Prejst na platbu', $url) ->line('🏝 dekujeme za Vasi objednavku. Potvrzenim objednavky se Vas ucet automaticky zaktivuje a vytvori se Vam digitalni prostor pro Vase dulezite dokumenty.')
->line('Dakujeme za zaujem o nase sluzby!'); ->line("Datovy tarif: Standard: $storage - $price")
->action('Prejst na platbu', $url)
->line('Dekujeme, Vas tym OasisDrive');
} }
/** /**
* Get the array representation of the notification. * Get the array representation of the notification.
* *
* @param mixed $notifiable * @param mixed $notifiable
* @return array * @return array
*/ */
public function toArray($notifiable) public function toArray($notifiable)