'integer', 'flight_time' => 'integer', 'balance' => 'double', 'timezone' => 'integer', ]; /** * Validation rules * * @var array */ public static $rules = [ ]; /** * Returns a 40 character API key that a user can use * @return string */ public static function generateApiKey() { $key = sha1(time() . mt_rand()); return $key; } public function pilot_id() { return $this->airline->icao.str_pad($this->id, 3, '0', STR_PAD_LEFT); } public function gravatar() { $size = 80; $default = 'https://en.gravatar.com/userimage/12856995/7c7c1da6387853fea65ff74983055386.png'; return "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $this->email) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size; } /** * Foreign Keys */ public function airline() { return $this->belongsTo('App\Models\Airline', 'airline_id'); } public function home_airport() { return $this->belongsTo('App\Models\Airport', 'home_airport_id'); } public function current_airport() { return $this->belongsTo('App\Models\Airport', 'curr_airport_id'); } public function flights() { return $this->hasMany('App\Models\UserFlight', 'user_id'); } public function pireps() { return $this->hasMany('App\Models\Pirep', 'user_id'); } public function rank() { return $this->belongsTo('App\Models\Rank', 'rank_id'); } }