diff --git a/Procfile b/Procfile index 38128ec6..dd368790 100644 --- a/Procfile +++ b/Procfile @@ -2,4 +2,4 @@ dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground php-fpm: /usr/local/sbin/php-fpm --nodaemonize nginx: /usr/local/bin/nginx #mysql: /usr/local/bin/mysqld -#mailhog: /usr/local/bin/mailhog +mailhog: /usr/local/bin/mailhog diff --git a/app/Database/migrations/2017_06_07_014930_create_settings_table.php b/app/Database/migrations/2017_06_07_014930_create_settings_table.php index e5699853..88b92483 100644 --- a/app/Database/migrations/2017_06_07_014930_create_settings_table.php +++ b/app/Database/migrations/2017_06_07_014930_create_settings_table.php @@ -13,19 +13,17 @@ class CreateSettingsTable extends Migration public function up() { Schema::create('settings', function (Blueprint $table) { - $table->increments('id'); + $table->string('id'); $table->unsignedInteger('order')->default(99); $table->string('name'); - $table->string('key'); $table->string('value'); $table->string('group')->nullable(); $table->string('type')->nullable(); $table->string('options')->nullable(); $table->string('description')->nullable(); + $table->primary('id'); $table->timestamps(); - $table->unique('key'); - $table->index('key'); }); /** @@ -33,86 +31,95 @@ class CreateSettingsTable extends Migration */ $settings = [ [ + 'id' => 'general_start_date', 'order' => 1, 'name' => 'Start Date', 'group' => 'general', - 'key' => 'general.start_date', 'value' => '', 'type' => 'date', 'description' => 'The date your VA started', ], [ + 'id' => 'general_admin_email', 'order' => 2, 'name' => 'Admin Email', 'group' => 'general', - 'key' => 'general.admin_email', 'value' => '', 'type' => 'text', 'description' => 'Email where notices, etc are sent', ], [ + 'id' => 'general_currency', 'order' => 3, 'name' => 'Currency to Use', 'group' => 'general', - 'key' => 'general.currency', 'value' => 'dollar', 'type' => 'select', 'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble', 'description' => 'Currency to show in the interface', ], [ + 'id' => 'flight_only_flights_from_current', 'order' => 10, 'name' => 'Flights from Current', 'group' => 'flights', - 'key' => 'flights.only_flights_from_current', 'value' => true, 'type' => 'boolean', 'description' => 'Only allow flights from current location', ], [ + 'id' => 'bids_disable_flight_on_bid', 'order' => 20, 'name' => 'Disable flight on bid', 'group' => 'bids', - 'key' => 'bids.disable_flight_on_bid', 'value' => true, 'type' => 'boolean', 'description' => 'When a flight is bid on, no one else can bid on it', ], [ + 'id' => 'bids_allow_multiple_bids', 'order' => 21, 'name' => 'Allow multiple bids', 'group' => 'bids', - 'key' => 'bids.allow_multiple_bids', 'value' => true, 'type' => 'boolean', 'description' => 'Whether or not someone can bid on multiple flights', ], [ + 'id' => 'pilots_id_length', 'order' => 30, - 'name' => 'Hide Inactive Pilots', + 'name' => 'Pilot ID Length', 'group' => 'pilots', - 'key' => 'pilots.hide_inactive', - 'value' => true, - 'type' => 'boolean', - 'description' => 'Don\'t show inactive pilots in the public view', + 'value' => 4, + 'type' => 'int', + 'description' => 'The length of a pilot\'s ID', ], [ + 'id' => 'pilot_auto_accept', 'order' => 31, 'name' => 'Auto Accept New Pilot', 'group' => 'pilots', - 'key' => 'pilot.auto_accept', 'value' => true, 'type' => 'boolean', 'description' => 'Automatically accept a pilot when they register', ], [ - 'order' => 32, - 'name' => 'Pilot ID Length', + 'id' => 'pilot_auto_leave_days', + 'order' => 31, + 'name' => 'Pilot to ON LEAVE days', 'group' => 'pilots', - 'key' => 'pilots.id_length', - 'value' => 4, + 'value' => 30, 'type' => 'int', - 'description' => 'The length of a pilot\'s ID', + 'description' => 'Automatically set a pilot to ON LEAVE status after N days of no activity', + ], + [ + 'id' => 'pilots_hide_inactive', + 'order' => 32, + 'name' => 'Hide Inactive Pilots', + 'group' => 'pilots', + 'value' => true, + 'type' => 'boolean', + 'description' => 'Don\'t show inactive pilots in the public view', ], ]; diff --git a/app/Listeners/NotificationEventListener.php b/app/Listeners/NotificationEventListener.php index c02ee607..63d9b676 100644 --- a/app/Listeners/NotificationEventListener.php +++ b/app/Listeners/NotificationEventListener.php @@ -5,6 +5,7 @@ namespace App\Listeners; use Log; use Illuminate\Support\Facades\Mail; +use App\Events\UserRegistered; use App\Models\Enums\UserState; /** @@ -39,6 +40,8 @@ class NotificationEventListener # First send the admin a notification $admin_email = setting('general.admin_email'); + Log::info('Sending admin notification email to "'.$admin_email.'"'); + if (!empty($admin_email)) { $email = new \App\Mail\Admin\UserRegistered($event->user); Mail::to($admin_email)->send($email); diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 2e478bc4..e9a1900f 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -1,16 +1,11 @@ id)) { + $model->id = str_replace('.', '_', strtolower($model->id)); + } + }); + } + } diff --git a/app/Repositories/SettingRepository.php b/app/Repositories/SettingRepository.php index 9afd1868..877ebb27 100644 --- a/app/Repositories/SettingRepository.php +++ b/app/Repositories/SettingRepository.php @@ -28,8 +28,8 @@ class SettingRepository extends BaseRepository implements CacheableInterface */ public function retrieve($key) { - $key = strtolower($key); - $setting = $this->findWhere(['key' => $key], ['type', 'value'])->first(); + $key = str_replace('.', '_', strtolower($key)); + $setting = $this->findWhere(['id' => $key], ['type', 'value'])->first(); if(!$setting) { return null; @@ -46,8 +46,12 @@ class SettingRepository extends BaseRepository implements CacheableInterface break; case 'int': case 'integer': + case 'number': return (int) $setting->value; break; + case 'float': + return (float) $setting->value; + break; default: return $setting->value; }