Updates to settings code for creating the ID and setting the order
This commit is contained in:
@@ -26,13 +26,21 @@ class CreateSettingsTable extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->addCounterGroups([
|
||||||
|
'general' => 1,
|
||||||
|
'flights' => 20,
|
||||||
|
'bids' => 40,
|
||||||
|
'pireps' => 60,
|
||||||
|
'pilots' => 80,
|
||||||
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial default settings
|
* Initial default settings
|
||||||
*/
|
*/
|
||||||
$settings = [
|
$settings = [
|
||||||
[
|
[
|
||||||
'id' => 'general_start_date',
|
'id' => $this->formatSettingId('general.start_date'),
|
||||||
'order' => 1,
|
'order' => $this->getNextOrderNumber('general'),
|
||||||
'name' => 'Start Date',
|
'name' => 'Start Date',
|
||||||
'group' => 'general',
|
'group' => 'general',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
@@ -40,8 +48,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'The date your VA started',
|
'description' => 'The date your VA started',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'general_admin_email',
|
'id' => $this->formatSettingId('general.admin_email'),
|
||||||
'order' => 2,
|
'order' => $this->getNextOrderNumber('general'),
|
||||||
'name' => 'Admin Email',
|
'name' => 'Admin Email',
|
||||||
'group' => 'general',
|
'group' => 'general',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
@@ -49,8 +57,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'Email where notices, etc are sent',
|
'description' => 'Email where notices, etc are sent',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'general_currency',
|
'id' => $this->formatSettingId('general.currency'),
|
||||||
'order' => 3,
|
'order' => $this->getNextOrderNumber('general'),
|
||||||
'name' => 'Currency to Use',
|
'name' => 'Currency to Use',
|
||||||
'group' => 'general',
|
'group' => 'general',
|
||||||
'value' => 'dollar',
|
'value' => 'dollar',
|
||||||
@@ -59,8 +67,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'Currency to show in the interface',
|
'description' => 'Currency to show in the interface',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'flight_only_flights_from_current',
|
'id' => $this->formatSettingId('flights.only_flights_from_current'),
|
||||||
'order' => 10,
|
'order' => $this->getNextOrderNumber('flights'),
|
||||||
'name' => 'Flights from Current',
|
'name' => 'Flights from Current',
|
||||||
'group' => 'flights',
|
'group' => 'flights',
|
||||||
'value' => true,
|
'value' => true,
|
||||||
@@ -68,8 +76,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'Only allow flights from current location',
|
'description' => 'Only allow flights from current location',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'bids_disable_flight_on_bid',
|
'id' => $this->formatSettingId('bids.disable_flight_on_bid'),
|
||||||
'order' => 20,
|
'order' => $this->getNextOrderNumber('bids'),
|
||||||
'name' => 'Disable flight on bid',
|
'name' => 'Disable flight on bid',
|
||||||
'group' => 'bids',
|
'group' => 'bids',
|
||||||
'value' => true,
|
'value' => true,
|
||||||
@@ -77,8 +85,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'When a flight is bid on, no one else can bid on it',
|
'description' => 'When a flight is bid on, no one else can bid on it',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'bids_allow_multiple_bids',
|
'id' => $this->formatSettingId('bids.allow_multiple_bids'),
|
||||||
'order' => 21,
|
'order' => $this->getNextOrderNumber('bids'),
|
||||||
'name' => 'Allow multiple bids',
|
'name' => 'Allow multiple bids',
|
||||||
'group' => 'bids',
|
'group' => 'bids',
|
||||||
'value' => true,
|
'value' => true,
|
||||||
@@ -86,8 +94,17 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'Whether or not someone can bid on multiple flights',
|
'description' => 'Whether or not someone can bid on multiple flights',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'pilots_id_length',
|
'id' => $this->formatSettingId('pireps.duplicate_check_time'),
|
||||||
'order' => 30,
|
'order' => $this->getNextOrderNumber('pireps'),
|
||||||
|
'name' => 'PIREP duplicate time check',
|
||||||
|
'group' => 'pireps',
|
||||||
|
'value' => 4,
|
||||||
|
'type' => 'int',
|
||||||
|
'description' => 'The time in minutes to check for a duplicate PIREP',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => $this->formatSettingId('pilots.id_length'),
|
||||||
|
'order' => $this->getNextOrderNumber('pilots'),
|
||||||
'name' => 'Pilot ID Length',
|
'name' => 'Pilot ID Length',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'value' => 4,
|
'value' => 4,
|
||||||
@@ -95,8 +112,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'The length of a pilot\'s ID',
|
'description' => 'The length of a pilot\'s ID',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'pilot_auto_accept',
|
'id' => $this->formatSettingId('pilot.auto_accept'),
|
||||||
'order' => 31,
|
'order' => $this->getNextOrderNumber('pilots'),
|
||||||
'name' => 'Auto Accept New Pilot',
|
'name' => 'Auto Accept New Pilot',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'value' => true,
|
'value' => true,
|
||||||
@@ -104,8 +121,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'Automatically accept a pilot when they register',
|
'description' => 'Automatically accept a pilot when they register',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'pilot_auto_leave_days',
|
'id' => $this->formatSettingId('pilot.auto_leave_days'),
|
||||||
'order' => 31,
|
'order' => $this->getNextOrderNumber('pilots'),
|
||||||
'name' => 'Pilot to ON LEAVE days',
|
'name' => 'Pilot to ON LEAVE days',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'value' => 30,
|
'value' => 30,
|
||||||
@@ -113,8 +130,8 @@ class CreateSettingsTable extends Migration
|
|||||||
'description' => 'Automatically set a pilot to ON LEAVE status after N days of no activity',
|
'description' => 'Automatically set a pilot to ON LEAVE status after N days of no activity',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'pilots_hide_inactive',
|
'id' => $this->formatSettingId('pilots.hide_inactive'),
|
||||||
'order' => 32,
|
'order' => $this->getNextOrderNumber('pilots'),
|
||||||
'name' => 'Hide Inactive Pilots',
|
'name' => 'Hide Inactive Pilots',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'value' => true,
|
'value' => true,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class FlightController extends AppBaseController
|
|||||||
$where = ['active' => true];
|
$where = ['active' => true];
|
||||||
|
|
||||||
// default restrictions on the flights shown. Handle search differently
|
// default restrictions on the flights shown. Handle search differently
|
||||||
if (config('phpvms.only_flights_from_current')) {
|
if (setting('flights.only_flights_from_current')) {
|
||||||
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,49 @@ use Illuminate\Database\Migrations\Migration as MigrationBase;
|
|||||||
|
|
||||||
class Migration extends MigrationBase
|
class Migration extends MigrationBase
|
||||||
{
|
{
|
||||||
|
protected $counters;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just make sure the dotted format converts to all underscores
|
||||||
|
*/
|
||||||
|
public function formatSettingId($id)
|
||||||
|
{
|
||||||
|
return str_replace('.', '_', $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a counter for groups with the start index. E.g:
|
||||||
|
* pireps: 10
|
||||||
|
* users: 30
|
||||||
|
*
|
||||||
|
* When calling getNextOrderNumber(users) 31, will be returned, then 32, and so on
|
||||||
|
* @param array $groups
|
||||||
|
*/
|
||||||
|
public function addCounterGroups(array $groups)
|
||||||
|
{
|
||||||
|
foreach($groups as $group => $start) {
|
||||||
|
$this->counters[$group] = $start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the next increment number from a group
|
||||||
|
* @param $group
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getNextOrderNumber($group)
|
||||||
|
{
|
||||||
|
if(!isset($this->counters[$group])) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$idx = $this->counters[$group];
|
||||||
|
++$this->counters[$group];
|
||||||
|
|
||||||
|
return $idx;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add rows to a table
|
* Add rows to a table
|
||||||
* @param $table
|
* @param $table
|
||||||
|
|||||||
Reference in New Issue
Block a user