Skip to content

Commit

Permalink
Custom Code for Pilot IDents (#1398)
Browse files Browse the repository at this point in the history
* Custom Code for Pilot IDents

Adds a new setting to customize the ident or to use a fixed icao code in a multi airline environment.

If settings is null/empty, airline icao will be used as like before.

* StyleFix
  • Loading branch information
FatihKoz committed Feb 7, 2022
1 parent 737b2f1 commit 9253d39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/Database/seeds/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@
options: ''
type: int
description: 'The length of a pilot''s ID'
- key: pilots.id_code
name: 'Pilot ID Code'
group: pilots
value: ''
options: ''
type: text
description: 'Fixed ICAO code for pilot IDs'
- key: pilots.auto_accept
name: 'Auto Accept New Pilot'
group: pilots
Expand Down
3 changes: 2 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ class User extends Authenticatable
public function getIdentAttribute(): string
{
$length = setting('pilots.id_length');
$ident_code = filled(setting('pilots.id_code')) ? setting('pilots.id_code') : optional($this->airline)->icao;

return optional($this->airline)->icao.str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT);
return $ident_code.str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT);
}

/**
Expand Down

0 comments on commit 9253d39

Please sign in to comment.