'integer', 'flight_time' => 'integer', 'transferred_time' => 'integer', 'balance' => 'double', 'state' => 'integer', 'status' => 'integer', ]; public static $rules = [ 'name' => 'required', 'email' => 'required|email', ]; /** * @return string */ public function getPilotIdAttribute() { $length = setting('pilots.id_length'); return $this->airline->icao.str_pad($this->id, $length, '0', STR_PAD_LEFT); } /** * @return string */ public function getIdentAttribute() { return $this->getPilotIdAttribute(); } /** * Shorthand for getting the timezone * @return string */ public function getTzAttribute(): string { return $this->timezone; } /** * Shorthand for setting the timezone * @param $value */ public function setTzAttribute($value) { $this->attributes['timezone'] = $value; } /** * @param mixed $size Size of the gravatar, in pixels * @return string */ public function gravatar($size = null) { $default = config('gravatar.default'); $uri = config('gravatar.url') .md5(strtolower(trim($this->email))).'?d='.urlencode($default); if ($size !== null) { $uri .= '&s='.$size; } return $uri; } /** * Foreign Keys */ public function airline() { return $this->belongsTo(Airline::class, 'airline_id'); } public function awards() { return $this->hasMany(UserAward::class, 'user_id'); } public function home_airport() { return $this->belongsTo(Airport::class, 'home_airport_id'); } public function current_airport() { return $this->belongsTo(Airport::class, 'curr_airport_id'); } public function last_pirep() { return $this->belongsTo(Pirep::class, 'last_pirep_id'); } public function bids() { return $this->hasMany(Bid::class, 'user_id'); } public function pireps() { return $this->hasMany(Pirep::class, 'user_id') ->where('state', '!=', PirepState::CANCELLED); } public function rank() { return $this->belongsTo(Rank::class, 'rank_id'); } }