Add additional settings; Use pilot id length from setting
This commit is contained in:
parent
695900a008
commit
e05976a982
@ -2,6 +2,7 @@
|
|||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="AndroidLintTypos" enabled="false" level="WARNING" enabled_by_default="false" />
|
<inspection_tool class="AndroidLintTypos" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="ClassOverridesFieldOfSuperClassInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="ForgottenDebugOutputInspection" enabled="true" level="ERROR" enabled_by_default="true">
|
<inspection_tool class="ForgottenDebugOutputInspection" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
<option name="configuration">
|
<option name="configuration">
|
||||||
<list>
|
<list>
|
||||||
|
@ -4,7 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Eloquent as Model;
|
use Eloquent as Model;
|
||||||
|
|
||||||
use App\Models\Traits\Uuids;
|
use App\Models\Traits\HashId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Flight
|
* Class Flight
|
||||||
@ -13,7 +13,7 @@ use App\Models\Traits\Uuids;
|
|||||||
*/
|
*/
|
||||||
class Flight extends Model
|
class Flight extends Model
|
||||||
{
|
{
|
||||||
use Uuids;
|
use HashId;
|
||||||
|
|
||||||
public $table = 'flights';
|
public $table = 'flights';
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Eloquent as Model;
|
use Eloquent as Model;
|
||||||
use App\Models\Traits\Uuids;
|
use App\Models\Traits\HashId;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
*/
|
*/
|
||||||
class Pirep extends Model
|
class Pirep extends Model
|
||||||
{
|
{
|
||||||
use Uuids;
|
use HashId;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
public $table = 'pireps';
|
public $table = 'pireps';
|
||||||
|
@ -5,21 +5,21 @@ namespace App\Models\Traits;
|
|||||||
use Hashids\Hashids;
|
use Hashids\Hashids;
|
||||||
|
|
||||||
|
|
||||||
trait Uuids
|
trait HashId
|
||||||
{
|
{
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
static::creating(function ($model) {
|
static::creating(function ($model)
|
||||||
|
{
|
||||||
$key = $model->getKeyName();
|
$key = $model->getKeyName();
|
||||||
|
|
||||||
if (empty($model->{$key})) {
|
if (empty($model->{$key})) {
|
||||||
$hashids = new Hashids('', 10);
|
$hashids = new Hashids('', 10);
|
||||||
|
|
||||||
$mt = str_replace('.', '', microtime(true));
|
$mt = str_replace('.', '', microtime(true));
|
||||||
|
|
||||||
$id = $hashids->encode($mt);
|
$id = $hashids->encode($mt);
|
||||||
|
|
||||||
$model->{$key} = $id;
|
$model->{$key} = $id;
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -73,18 +73,15 @@ class User extends Authenticatable
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $hidden
|
protected $hidden = [
|
||||||
= [
|
|
||||||
'password',
|
'password',
|
||||||
'remember_token',
|
'remember_token',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts
|
protected $casts = [
|
||||||
= [
|
|
||||||
'flights' => 'integer',
|
'flights' => 'integer',
|
||||||
'flight_time' => 'integer',
|
'flight_time' => 'integer',
|
||||||
'balance' => 'double',
|
'balance' => 'double',
|
||||||
'timezone' => 'integer',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,9 +103,10 @@ class User extends Authenticatable
|
|||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pilot_id()
|
public function getPilotIdAttribute($value)
|
||||||
{
|
{
|
||||||
return $this->airline->icao.str_pad($this->id, 3, '0', STR_PAD_LEFT);
|
$length = setting('pilots.id_length');
|
||||||
|
return $this->airline->icao . str_pad($this->id, $length, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gravatar()
|
public function gravatar()
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Repositories\Traits\CacheableRepository;
|
use App\Repositories\Traits\CacheableRepository;
|
||||||
use Prettus\Repository\Contracts\CacheableInterface;
|
|
||||||
|
|
||||||
class SettingRepository extends BaseRepository implements CacheableInterface
|
class SettingRepository extends BaseRepository implements CacheableInterface
|
||||||
{
|
{
|
||||||
@ -16,17 +18,44 @@ class SettingRepository extends BaseRepository implements CacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a setting, reading it from the cache
|
* Get a setting, reading it from the cache possibly
|
||||||
* @param array $key
|
* @param string $key
|
||||||
* @return mixed|void
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($key)
|
public function retrieve($key)
|
||||||
{
|
{
|
||||||
|
$key = strtolower($key);
|
||||||
|
$setting = $this->findWhere(['key' => $key], ['type', 'value'])->first();
|
||||||
|
|
||||||
|
if(!$setting) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set($key, $value)
|
# cast some types
|
||||||
{
|
switch($setting->type) {
|
||||||
|
case 'bool':
|
||||||
|
case 'boolean':
|
||||||
|
return (bool) $setting->value;
|
||||||
|
break;
|
||||||
|
case 'date':
|
||||||
|
return Carbon::parse($setting->value);
|
||||||
|
break;
|
||||||
|
case 'int':
|
||||||
|
case 'integer':
|
||||||
|
return (int) $setting->value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $setting->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store($key, $value)
|
||||||
|
{
|
||||||
|
$setting = $this->findWhere(['key' => $key], ['id'])->first();
|
||||||
|
if (!$setting) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->update(['value' => $value], $setting->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ if (!function_exists('setting')) {
|
|||||||
{
|
{
|
||||||
$settingRepo = app('setting');
|
$settingRepo = app('setting');
|
||||||
if($value === null) {
|
if($value === null) {
|
||||||
return $settingRepo->get($key);
|
return $settingRepo->retrieve($key);
|
||||||
} else {
|
} else {
|
||||||
$settingRepo->set($key, $value);
|
$settingRepo->set($key, $value);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class CreateUsersTable extends Migration
|
|||||||
$table->integer('rank_id')->nullable()->unsigned();
|
$table->integer('rank_id')->nullable()->unsigned();
|
||||||
$table->string('home_airport_id', 5)->nullable();
|
$table->string('home_airport_id', 5)->nullable();
|
||||||
$table->string('curr_airport_id', 5)->nullable();
|
$table->string('curr_airport_id', 5)->nullable();
|
||||||
$table->uuid('last_pirep_id')->nullable();
|
$table->string('last_pirep_id')->nullable();
|
||||||
$table->bigInteger('flights')->unsigned()->default(0);
|
$table->bigInteger('flights')->unsigned()->default(0);
|
||||||
$table->bigInteger('flight_time')->unsigned()->default(0);
|
$table->bigInteger('flight_time')->unsigned()->default(0);
|
||||||
$table->decimal('balance', 19, 2)->nullable();
|
$table->decimal('balance', 19, 2)->nullable();
|
||||||
|
@ -60,7 +60,7 @@ class CreateSettingsTable extends Migration
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'order' => 20,
|
'order' => 20,
|
||||||
'name' => 'Disable flights on bid',
|
'name' => 'Disable flight on bid',
|
||||||
'group' => 'bids',
|
'group' => 'bids',
|
||||||
'key' => 'bids.disable_flight_on_bid',
|
'key' => 'bids.disable_flight_on_bid',
|
||||||
'value' => true,
|
'value' => true,
|
||||||
@ -85,6 +85,15 @@ class CreateSettingsTable extends Migration
|
|||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Don\'t show inactive pilots in the public view',
|
'description' => 'Don\'t show inactive pilots in the public view',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'order' => 31,
|
||||||
|
'name' => 'Pilot ID Length',
|
||||||
|
'group' => 'pilots',
|
||||||
|
'key' => 'pilots.id_length',
|
||||||
|
'value' => 4,
|
||||||
|
'type' => 'int',
|
||||||
|
'description' => 'The length of a pilot\'s ID',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->addData('settings', $settings);
|
$this->addData('settings', $settings);
|
||||||
|
24
package-lock.json
generated
24
package-lock.json
generated
@ -219,7 +219,7 @@
|
|||||||
"arr-flatten": {
|
"arr-flatten": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
|
||||||
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
|
"integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"array-differ": {
|
"array-differ": {
|
||||||
@ -2902,7 +2902,7 @@
|
|||||||
"duplexify": {
|
"duplexify": {
|
||||||
"version": "3.5.1",
|
"version": "3.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.1.tgz",
|
||||||
"integrity": "sha512-j5goxHTwVED1Fpe5hh3q9R93Kip0Bg2KVAt4f8CEYM3UEwYcPSvWbXaUQOzdX/HtiNomipv+gU7ASQPDbV7pGQ==",
|
"integrity": "sha1-ThUWvmiDi8kKSZlPCzmm5ZYL780=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"end-of-stream": "1.4.0",
|
"end-of-stream": "1.4.0",
|
||||||
@ -5243,7 +5243,7 @@
|
|||||||
"hosted-git-info": {
|
"hosted-git-info": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz",
|
||||||
"integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==",
|
"integrity": "sha1-bWDjSzq7yDEwYsO3mO+NkBoHrzw=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"hpack.js": {
|
"hpack.js": {
|
||||||
@ -5843,7 +5843,7 @@
|
|||||||
"is-plain-object": {
|
"is-plain-object": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
||||||
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
|
"integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isobject": "3.0.1"
|
"isobject": "3.0.1"
|
||||||
@ -7031,7 +7031,7 @@
|
|||||||
"node-emoji": {
|
"node-emoji": {
|
||||||
"version": "1.8.1",
|
"version": "1.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.8.1.tgz",
|
||||||
"integrity": "sha512-+ktMAh1Jwas+TnGodfCfjUbJKoANqPaJFN0z0iqh41eqD8dvguNzcitVSBSVK1pidz0AqGbLKcoVuVLRVZ/aVg==",
|
"integrity": "sha1-buxr+wdCHiFIx1xrunJCH4UwqCY=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lodash.toarray": "4.4.0"
|
"lodash.toarray": "4.4.0"
|
||||||
@ -7218,7 +7218,7 @@
|
|||||||
"normalize-package-data": {
|
"normalize-package-data": {
|
||||||
"version": "2.4.0",
|
"version": "2.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
|
||||||
"integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
|
"integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"hosted-git-info": "2.5.0",
|
"hosted-git-info": "2.5.0",
|
||||||
@ -7266,7 +7266,7 @@
|
|||||||
"npmlog": {
|
"npmlog": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
|
||||||
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
|
"integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"are-we-there-yet": "1.1.4",
|
"are-we-there-yet": "1.1.4",
|
||||||
@ -9790,7 +9790,7 @@
|
|||||||
"randomatic": {
|
"randomatic": {
|
||||||
"version": "1.1.7",
|
"version": "1.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
|
||||||
"integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==",
|
"integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-number": "3.0.0",
|
"is-number": "3.0.0",
|
||||||
@ -10341,7 +10341,7 @@
|
|||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
|
"integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"sass-graph": {
|
"sass-graph": {
|
||||||
@ -11707,7 +11707,7 @@
|
|||||||
"uuid": {
|
"uuid": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
|
||||||
"integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==",
|
"integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"vali-date": {
|
"vali-date": {
|
||||||
@ -12130,7 +12130,7 @@
|
|||||||
"which": {
|
"which": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
|
||||||
"integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==",
|
"integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "2.0.0"
|
"isexe": "2.0.0"
|
||||||
@ -12145,7 +12145,7 @@
|
|||||||
"wide-align": {
|
"wide-align": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
|
||||||
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
|
"integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"string-width": "1.0.2"
|
"string-width": "1.0.2"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<img src="{!! $pirep->pilot->gravatar() !!}" />
|
<img src="{!! $pirep->pilot->gravatar() !!}" />
|
||||||
</div>--}}
|
</div>--}}
|
||||||
Filed By: <a href="{!! route('admin.users.edit', [$pirep->pilot->id]) !!}" target="_blank">
|
Filed By: <a href="{!! route('admin.users.edit', [$pirep->pilot->id]) !!}" target="_blank">
|
||||||
{!! $pirep->pilot->pilot_id() !!} {!! $pirep->pilot->name !!}
|
{!! $pirep->pilot->pilot_id !!} {!! $pirep->pilot->name !!}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
<table>
|
<table>
|
||||||
@foreach($users as $u)
|
@foreach($users as $u)
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-right: 10px;">{!! $u->pilot_id() !!}</td>
|
<td style="padding-right: 10px;">{!! $u->pilot_id !!}</td>
|
||||||
<td><span class="description">{!! $u->name !!}</span></td>
|
<td><span class="description">{!! $u->name !!}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
Loading…
Reference in New Issue
Block a user