-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
218 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace App\Jobs\TeamUsers; | ||
|
||
use App\Models\TeamUser; | ||
use App\Models\User; | ||
use App\Notifications\Mail\TeamUsers\SendTeamUserInvitationEmailNotification; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Foundation\Queue\Queueable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class SendTeamUserInvitationEmail implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* Create a new job instance. | ||
*/ | ||
public function __construct(public TeamUser $teamUser) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
*/ | ||
public function handle(): void | ||
{ | ||
Log::info('SendTeamUserInvitationEmail'); | ||
$userToNotify = User::find($this->teamUser->user_id); | ||
|
||
if($userToNotify) | ||
{ | ||
$userToNotify->current_team_id = $this->teamUser->team_id; | ||
$userToNotify->saveQuietly(); | ||
|
||
$userToNotify->notify(new SendTeamUserInvitationEmailNotification($this->teamUser)); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
app/Notifications/Mail/TeamUsers/SendTeamUserInvitationEmailNotification.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App\Notifications\Mail\TeamUsers; | ||
|
||
use App\Models\Team; | ||
use App\Models\TeamUser; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Notifications\Notification; | ||
|
||
class SendTeamUserInvitationEmailNotification extends Notification implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* Create a new notification instance. | ||
*/ | ||
public function __construct(public TeamUser $teamUser) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* 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 | ||
{ | ||
$team = Team::find($this->teamUser->team_id); | ||
|
||
return (new MailMessage) | ||
->subject('You have been invited to join ' . $team->name. ' - '.config('app.name')) | ||
->line('You have been invited to join team "' . $team->name. '" on '.config('app.name').'.') | ||
->line('An account has been created for you on the team, but if you have never logged in to use the system, you may need to reset your password in order to log in.') | ||
->line('Please follow the button below to reset your password and log in.') | ||
->action('Reset your password & log in', url('/forgot-password')) | ||
->line('Thank you for using our application!'); | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(object $notifiable): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters