* Discord notifications for events #433 * Style fixes * Check for blank webhook urls and disable * Cleanup items after review * Changes and fixes * Style fixes * Don't load env for testing * Fix status text * Refactor saving fields/fares so events get the latest data * Cleanup * Style fixes
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\Model;
|
||||
use App\Events\PirepStateChange;
|
||||
use App\Events\PirepStatusChange;
|
||||
use App\Models\Enums\AcarsType;
|
||||
use App\Models\Enums\PirepFieldSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
@@ -10,7 +12,9 @@ use App\Models\Traits\HashIdTrait;
|
||||
use App\Support\Units\Distance;
|
||||
use App\Support\Units\Fuel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Kleemans\AttributeEvents;
|
||||
|
||||
/**
|
||||
* @property string id
|
||||
@@ -44,8 +48,8 @@ use Illuminate\Support\Collection;
|
||||
* @property Flight|null flight
|
||||
* @property Collection fields
|
||||
* @property string status
|
||||
* @property PirepState state
|
||||
* @property int source
|
||||
* @property int state
|
||||
* @property int source
|
||||
* @property string source_name
|
||||
* @property Carbon submitted_at
|
||||
* @property Carbon created_at
|
||||
@@ -57,7 +61,9 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class Pirep extends Model
|
||||
{
|
||||
use AttributeEvents;
|
||||
use HashIdTrait;
|
||||
use Notifiable;
|
||||
|
||||
public $table = 'pireps';
|
||||
|
||||
@@ -137,6 +143,14 @@ class Pirep extends Model
|
||||
'route' => 'nullable',
|
||||
];
|
||||
|
||||
/**
|
||||
* Auto-dispatch events for lifecycle state changes
|
||||
*/
|
||||
protected $dispatchesEvents = [
|
||||
'status:*' => PirepStatusChange::class,
|
||||
'state:*' => PirepStateChange::class,
|
||||
];
|
||||
|
||||
/*
|
||||
* If a PIREP is in these states, then it can't be changed.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user