Backend changes separating id from pilot_id

This commit is contained in:
Nabeel Shahzad
2019-07-16 13:54:14 -04:00
parent 454776ecd4
commit 3e1d9080df
21 changed files with 454 additions and 34 deletions

View File

@@ -10,14 +10,17 @@ use Illuminate\Notifications\Notifiable;
use Laratrust\Traits\LaratrustUserTrait;
/**
* @property int id
* @property int id
* @property int pilot_id
* @property string name
* @property string email
* @property string password
* @property string api_key
* @property mixed ident
* @property mixed timezone
* @property string ident
* @property string curr_airport_id
* @property string home_airport_id
* @property Airline airline
* @property Flight[] flights
* @property string flight_time
* @property string remember_token
@@ -45,9 +48,11 @@ class User extends Authenticatable
public $journal_type = JournalType::USER;
protected $fillable = [
'id',
'name',
'email',
'password',
'pilot_id',
'airline_id',
'rank_id',
'api_key',
@@ -78,6 +83,8 @@ class User extends Authenticatable
];
protected $casts = [
'id' => 'integer',
'pilot_id' => 'integer',
'flights' => 'integer',
'flight_time' => 'integer',
'transfer_time' => 'integer',
@@ -96,19 +103,11 @@ class User extends Authenticatable
/**
* @return string
*/
public function getPilotIdAttribute()
public function getIdentAttribute()
{
$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();
return $this->airline->icao . str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT);
}
/**