Added achievement data
This commit is contained in:
@@ -37,10 +37,12 @@ class Achievement extends Model
|
||||
'difficulty_description',
|
||||
'achievement_category_id',
|
||||
'achievement_difficulty_id',
|
||||
'threshold',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'progressive' => 'boolean',
|
||||
'threshold' => 'integer',
|
||||
];
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
@@ -17,6 +17,7 @@ class Airline extends Model
|
||||
'name',
|
||||
'internal_name',
|
||||
'country_id',
|
||||
'alliance_id',
|
||||
'active',
|
||||
'logo',
|
||||
];
|
||||
@@ -25,7 +26,6 @@ class Airline extends Model
|
||||
'active' => 'boolean',
|
||||
];
|
||||
|
||||
|
||||
public $timestamps = false;
|
||||
protected $appends = [
|
||||
'display_name',
|
||||
@@ -50,6 +50,11 @@ class Airline extends Model
|
||||
);
|
||||
}
|
||||
|
||||
public function alliance(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Alliance::class);
|
||||
}
|
||||
|
||||
public function country(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Country::class);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Alliance extends Model
|
||||
{
|
||||
protected $table = 'alliances';
|
||||
|
||||
protected $fillable = [
|
||||
'internal_name',
|
||||
'name',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'internal_name' => 'string',
|
||||
];
|
||||
|
||||
public function airlines(): HasMany
|
||||
{
|
||||
return $this->hasMany(Airline::class);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -13,12 +13,15 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
use App\Traits\HasAchievements;
|
||||
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
use HasFactory, Notifiable, HasAchievements;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
@@ -148,6 +148,14 @@ class UserFlight extends Model
|
||||
);
|
||||
}
|
||||
|
||||
public function isDomestic() : bool{
|
||||
return $this->departureAirport->region->country_id == $this->arrivalAirport->region->country_id;
|
||||
}
|
||||
|
||||
public function isInternational() : bool{
|
||||
return !$this->isDomestic();
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
Reference in New Issue
Block a user