Added sockets for notifications
This commit is contained in:
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UserFlight extends Model
|
||||
@@ -30,12 +31,14 @@ class UserFlight extends Model
|
||||
'crew_type_id',
|
||||
'note',
|
||||
'auto_update',
|
||||
'departure_processed_at'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'departure_date' => 'immutable_datetime',
|
||||
'arrival_date' => 'immutable_datetime',
|
||||
'auto_update' => 'boolean',
|
||||
'departure_processed_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
@@ -50,9 +53,17 @@ class UserFlight extends Model
|
||||
'livery_url',
|
||||
'scope',
|
||||
'range',
|
||||
'region_range'
|
||||
'region_range',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (UserFlight $flight) {
|
||||
$flight->departure_processed_at = now();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function calculateGreatCircleDistance(): float{
|
||||
$earthRadiusKm = 6371;
|
||||
[$depLat, $depLong] = [$this->departureAirport->latitude_deg, $this->departureAirport->longitude_deg];
|
||||
@@ -182,7 +193,8 @@ class UserFlight extends Model
|
||||
return !$this->isDomestic();
|
||||
}
|
||||
|
||||
public function otherUsersOnFlight(){
|
||||
public function otherUsersOnFlight(): Collection
|
||||
{
|
||||
return UserFlight::where('user_id', '!=', $this->user_id)
|
||||
->where('departure_airport_id', $this->departure_airport_id)
|
||||
->where('arrival_airport_id', $this->arrival_airport_id)
|
||||
|
||||
Reference in New Issue
Block a user