2020-06-26 23:32:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
2020-08-31 21:06:00 +00:00
|
|
|
use App\Facades\Options;
|
|
|
|
use App\Traits\Cancellable;
|
2020-06-26 23:32:33 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
use Illuminate\Notifications\Messages\SlackMessage;
|
|
|
|
use Illuminate\Notifications\Notification;
|
2020-10-21 00:29:50 +00:00
|
|
|
use App\Application;
|
2020-06-26 23:32:33 +00:00
|
|
|
|
|
|
|
class ApplicationApproved extends Notification implements ShouldQueue
|
|
|
|
{
|
2020-08-31 21:06:00 +00:00
|
|
|
use Queueable, Cancellable;
|
2020-06-26 23:32:33 +00:00
|
|
|
|
|
|
|
public $application;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new notification instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(Application $application)
|
|
|
|
{
|
|
|
|
$this->application = $application;
|
|
|
|
}
|
2020-08-31 21:06:00 +00:00
|
|
|
|
|
|
|
public function channels()
|
|
|
|
{
|
|
|
|
return $this->chooseChannelsViaOptions();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function optOut($notifiable)
|
2020-06-26 23:32:33 +00:00
|
|
|
{
|
2020-08-31 21:06:00 +00:00
|
|
|
return Options::getOption('notify_applicant_approved') !== 1;
|
2020-06-26 23:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
|
|
*/
|
|
|
|
public function toMail($notifiable)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
|
2020-06-26 23:32:33 +00:00
|
|
|
return (new MailMessage)
|
|
|
|
->from(config('notification.sender.address'), config('notification.sender.name'))
|
2020-10-21 00:29:50 +00:00
|
|
|
->subject(config('app.name') . ' - ' . $this->application->response->vacancy->vacancyName . ' application approved')
|
2020-06-26 23:32:33 +00:00
|
|
|
->line('<br />')
|
|
|
|
->line('Congratulations! Our Staff team has reviewed your application today, and your application has been approved.')
|
|
|
|
->line('You have just received the Reviewer role, which allows you to view and vote on other applications.')
|
|
|
|
->line('Your in-game rank should be updated network-wide in the next few minutes, allowing you to perform staff duties.')
|
|
|
|
->line('Please join a voice channel when possible for your training meeting, if this has been mentioned by your interviewer.')
|
|
|
|
->line('<br />')
|
|
|
|
->line('Good luck and welcome aboard!')
|
|
|
|
->action('Sign in', url(route('login')))
|
|
|
|
->line('Thank you!');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toSlack($notifiable)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
|
2020-06-26 23:32:33 +00:00
|
|
|
$url = route('showSingleProfile', ['user' => $notifiable->id]);
|
|
|
|
$roles = implode(', ', $notifiable->roles->pluck('name')->all());
|
|
|
|
|
|
|
|
return (new SlackMessage)
|
|
|
|
->success()
|
|
|
|
->content('A user has been approved on the team. Welcome aboard!')
|
2020-10-21 00:29:50 +00:00
|
|
|
->attachment(function($attachment) use ($notifiable, $url, $roles){
|
2020-06-26 23:32:33 +00:00
|
|
|
$attachment->title('New staff member')
|
|
|
|
->fields([
|
|
|
|
'Name' => $notifiable->name,
|
|
|
|
'Email' => $notifiable->email,
|
2020-10-21 00:29:50 +00:00
|
|
|
'Roles' => $roles
|
2020-06-26 23:32:33 +00:00
|
|
|
])
|
|
|
|
->action('View profile', $url);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the array representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($notifiable)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|