Added achievement data
This commit is contained in:
+15
-5
@@ -2,18 +2,16 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use App\Http\Controllers\UserFlightController;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
use App\Traits\HasAchievements;
|
||||
use App\Models\Notification;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
@@ -21,7 +19,9 @@ class User extends Authenticatable
|
||||
{
|
||||
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable, HasAchievements;
|
||||
use HasFactory, HasAchievements, HasApiTokens;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -36,6 +36,11 @@ class User extends Authenticatable
|
||||
];
|
||||
}
|
||||
|
||||
public function achievements(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserAchievement::class);
|
||||
}
|
||||
|
||||
public function resolveRouteBinding($value, $field = null): ?User
|
||||
{
|
||||
return $this->where('name', 'ilike', $value)->firstOrFail();
|
||||
@@ -69,4 +74,9 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->following()->where('followee_id', $user->id)->exists();
|
||||
}
|
||||
|
||||
public function notifications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Notification::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class UserAction extends Model
|
||||
'flight_booked' => 'Flight Booked',
|
||||
'flight_cancelled' => 'Flight Cancelled',
|
||||
'flight_updated' => 'Flight Updated',
|
||||
'flight_imported' => 'Flight Imported',
|
||||
'flight_imported' => 'Flight Imported from FR24',
|
||||
'flight_logged' => 'Flight Logged',
|
||||
'flight_deleted' => 'Flight Deleted',
|
||||
default => 'Unknown Action'
|
||||
|
||||
@@ -156,6 +156,23 @@ class UserFlight extends Model
|
||||
return !$this->isDomestic();
|
||||
}
|
||||
|
||||
public static function snapshot($userFlightId){
|
||||
return UserFlight::with([
|
||||
'departureAirport',
|
||||
'departureAirport.region.country',
|
||||
'arrivalAirport',
|
||||
'arrivalAirport.region.country',
|
||||
'aircraft',
|
||||
'airline',
|
||||
'airline.country',
|
||||
'airline.alliance',
|
||||
'flightClass',
|
||||
'seatType',
|
||||
'flightReason',
|
||||
'crewType',
|
||||
])->find($userFlightId)->toArray();
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
Reference in New Issue
Block a user