30
app/Listeners/NewUser.php
Executable file
30
app/Listeners/NewUser.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class NewUser
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@@ -49,10 +49,11 @@ class OnUserRegistration
|
||||
// TODO: Send push notification to online admins via browser (w/ pusher)
|
||||
Log::info('User '.$event->user->name.' has just registered for an account.');
|
||||
|
||||
foreach (User::all() as $user) {
|
||||
if ($user->hasRole('admin')) {
|
||||
$user->notify(new NewUser($event->user));
|
||||
}
|
||||
}
|
||||
User::whereHas('roles', function ($q) {
|
||||
$q->where('name', 'admin');
|
||||
})->get()->each(function ($user, $key) use ($event) {
|
||||
$user->notify(new NewUser($event->user));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -45,11 +45,15 @@ class PromoteUser
|
||||
*/
|
||||
public function handle(ApplicationApprovedEvent $event)
|
||||
{
|
||||
Log::info('User '.$event->application->user->name . 'has just been promoted (application approved)');
|
||||
Log::info('User promoted automatically (application approved)', [
|
||||
'user' => $event->application->user->name,
|
||||
'vacancy' => $event->application->response->vacancy->vacancyName,
|
||||
'role' => 'staff'
|
||||
]);
|
||||
|
||||
$event->application->setStatus('APPROVED');
|
||||
$event->application->response->vacancy->decrease();
|
||||
$event->application->user->assignRole('reviewer');
|
||||
$event->application->user->assignRole('staff');
|
||||
|
||||
$event->application->user->notify(new ApplicationApproved($event->application));
|
||||
}
|
||||
|
Reference in New Issue
Block a user