feat:invitation email for shared portfolios
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class InvitedToPortfolioNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public Portfolio $portfolio,
|
||||
public User $sender,
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
|
||||
return (new MailMessage)
|
||||
->replyTo($this->sender->email, $this->sender->name)
|
||||
->greeting('Hey there! 👋')
|
||||
->subject("{$this->sender->name} invited you to {$this->portfolio->title} on Investbrain!")
|
||||
->line("{$this->sender->name} has invited you to **{$this->portfolio->title}** on Investbrain, Smart open-source investment tracker that consolidates and monitors market performance across your different brokerages.")
|
||||
->line('Once you\'re in, you\'ll be able to see holdings, dividends, market performance and more!')
|
||||
->action("Get Started", route('portfolio.show', ['portfolio' => $this->portfolio->id]))
|
||||
->line("If you have any questions, you can reply to this email.")
|
||||
->salutation("See you there,\n". e($this->sender->name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@props(['title' => ''])
|
||||
|
||||
<div {{ $attributes->merge(['class' => 'flex items-center mb-6']) }} class="">
|
||||
<h1 class="text-2xl font-medium mr-3"> {{ $title }} </h1>
|
||||
<h1 class="text-2xl font-medium mr-3 truncate"> {{ $title }} </h1>
|
||||
|
||||
{{ $slot }}
|
||||
</div>
|
||||
@@ -6,6 +6,7 @@ use Livewire\Attributes\Rule;
|
||||
use Livewire\Volt\Component;
|
||||
use Illuminate\Support\Collection;
|
||||
use Mary\Traits\Toast;
|
||||
use App\Notifications\InvitedToPortfolioNotification;
|
||||
|
||||
new class extends Component {
|
||||
|
||||
@@ -99,7 +100,14 @@ new class extends Component {
|
||||
'full_access' => $this->fullAccess
|
||||
];
|
||||
|
||||
$this->portfolio->users()->sync($this->permissions);
|
||||
$sync = $this->portfolio->users()->sync($this->permissions);
|
||||
|
||||
if (!empty($sync['attached'])) {
|
||||
|
||||
foreach($sync['attached'] as $newUserId) {
|
||||
User::find($newUserId)->notify(new InvitedToPortfolioNotification($this->portfolio, auth()->user()));
|
||||
};
|
||||
}
|
||||
|
||||
$this->success(__('Shared portfolio with user'));
|
||||
$this->portfolio->refresh();
|
||||
@@ -233,6 +241,5 @@ new class extends Component {
|
||||
<x-button class="btn-sm block mt-4" @click="$dispatch('toggle-add-user-modal')">
|
||||
{{ __('Add People') }}
|
||||
</x-button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
+1
-1
@@ -37,7 +37,7 @@
|
||||
|
||||
{{-- Salutation --}}
|
||||
@if (! empty($salutation))
|
||||
{{ $salutation }}
|
||||
{!! nl2br($salutation) !!}
|
||||
@else
|
||||
@lang('Regards,')<br>
|
||||
{{ config('app.name') }}
|
||||
|
||||
Reference in New Issue
Block a user