391 Notification refactorings (#441)

* Refactor notifications to allow easier plugins

* Notification refactoring

* Formatting

* Move news to NewsService; cleanup of events

* More refactoring; added send email out for news item and the template

* Formatting

* Formatting
This commit is contained in:
Nabeel S
2019-11-20 10:16:01 -05:00
committed by GitHub
parent 02973a0f22
commit ea3ab21beb
66 changed files with 754 additions and 718 deletions

12
app/Events/BaseEvent.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
}

View File

@@ -2,20 +2,6 @@
namespace App\Events;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the hourly cron is run
*/
class CronHourly
class CronHourly extends BaseEvent
{
use Dispatchable, SerializesModels;
/**
* CronHourly constructor.
*/
public function __construct()
{
}
}

View File

@@ -2,21 +2,10 @@
namespace App\Events;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the monthly cron is run
* It happens after all of the default nightly tasks
*/
class CronMonthly
class CronMonthly extends BaseEvent
{
use Dispatchable, SerializesModels;
/**
* CronMonthly constructor.
*/
public function __construct()
{
}
}

View File

@@ -2,21 +2,10 @@
namespace App\Events;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the daily cron is run
* It happens after all of the default nightly tasks
*/
class CronNightly
class CronNightly extends BaseEvent
{
use Dispatchable, SerializesModels;
/**
* CronNightly constructor.
*/
public function __construct()
{
}
}

View File

@@ -2,20 +2,12 @@
namespace App\Events;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the weekly cron is run
* It happens after all of the default nightly tasks
*/
class CronWeekly
class CronWeekly extends BaseEvent
{
use Dispatchable, SerializesModels;
/**
* CronWeekly constructor.
*/
public function __construct()
{
}

View File

@@ -3,8 +3,6 @@
namespace App\Events;
use App\Models\Pirep;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* This event is dispatched when the expenses for a flight report
@@ -27,9 +25,8 @@ use Illuminate\Queue\SerializesModels;
*
* The event will have a copy of the PIREP model, if it's applicable
*/
class Expenses
class Expenses extends BaseEvent
{
use Dispatchable, SerializesModels;
public $pirep;
/**

15
app/Events/NewsAdded.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace App\Events;
use App\Models\News;
class NewsAdded extends BaseEvent
{
public $news;
public function __construct(News $news)
{
$this->news = $news;
}
}

View File

@@ -3,24 +3,11 @@
namespace App\Events;
use App\Models\Pirep;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Class PirepAccepted
*/
class PirepAccepted
class PirepAccepted extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $pirep;
/**
* PirepAccepted constructor.
*
* @param Pirep $pirep
*/
public function __construct(Pirep $pirep)
{
$this->pirep = $pirep;

View File

@@ -3,13 +3,9 @@
namespace App\Events;
use App\Models\Pirep;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class PirepFiled
class PirepFiled extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $pirep;
public function __construct(Pirep $pirep)

View File

@@ -3,24 +3,11 @@
namespace App\Events;
use App\Models\Pirep;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Class PirepRejected
*/
class PirepRejected
class PirepRejected extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $pirep;
/**
* PirepRejected constructor.
*
* @param Pirep $pirep
*/
public function __construct(Pirep $pirep)
{
$this->pirep = $pirep;

View File

@@ -3,24 +3,11 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Class TestEvent
*/
class TestEvent
class TestEvent extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $user;
/**
* Create a new event instance.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;

View File

@@ -3,24 +3,11 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Class UserAccepted
*/
class UserAccepted
class UserAccepted extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $user;
/**
* UserAccepted constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;

View File

@@ -3,24 +3,11 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Class UserRegistered
*/
class UserRegistered
class UserRegistered extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $user;
/**
* UserRegistered constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;

View File

@@ -3,26 +3,15 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Event triggered when a user's state changes
*/
class UserStateChanged
class UserStateChanged extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $old_state;
public $user;
/**
* UserStateChanged constructor.
*
* @param User $user
* @param $old_state
*/
public function __construct(User $user, $old_state)
{
$this->old_state = $old_state;

View File

@@ -3,26 +3,18 @@
namespace App\Events;
use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
/**
* Class UserStatsChanged
*/
class UserStatsChanged
class UserStatsChanged extends BaseEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $stat_name;
public $old_value;
public $user;
/*
* When a user's stats change. Stats changed match the field name:
* airport
* flights
* rank
* airport
* flights
* rank
*/
public function __construct(User $user, $stat_name, $old_value)
{