Change setting table ID to string, handle the converison of . to _
This commit is contained in:
parent
528a7c7440
commit
948338d2b6
2
Procfile
2
Procfile
@ -2,4 +2,4 @@ dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground
|
|||||||
php-fpm: /usr/local/sbin/php-fpm --nodaemonize
|
php-fpm: /usr/local/sbin/php-fpm --nodaemonize
|
||||||
nginx: /usr/local/bin/nginx
|
nginx: /usr/local/bin/nginx
|
||||||
#mysql: /usr/local/bin/mysqld
|
#mysql: /usr/local/bin/mysqld
|
||||||
#mailhog: /usr/local/bin/mailhog
|
mailhog: /usr/local/bin/mailhog
|
||||||
|
@ -13,19 +13,17 @@ class CreateSettingsTable extends Migration
|
|||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('settings', function (Blueprint $table) {
|
Schema::create('settings', function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->string('id');
|
||||||
$table->unsignedInteger('order')->default(99);
|
$table->unsignedInteger('order')->default(99);
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('key');
|
|
||||||
$table->string('value');
|
$table->string('value');
|
||||||
$table->string('group')->nullable();
|
$table->string('group')->nullable();
|
||||||
$table->string('type')->nullable();
|
$table->string('type')->nullable();
|
||||||
$table->string('options')->nullable();
|
$table->string('options')->nullable();
|
||||||
$table->string('description')->nullable();
|
$table->string('description')->nullable();
|
||||||
|
|
||||||
|
$table->primary('id');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->unique('key');
|
|
||||||
$table->index('key');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,86 +31,95 @@ class CreateSettingsTable extends Migration
|
|||||||
*/
|
*/
|
||||||
$settings = [
|
$settings = [
|
||||||
[
|
[
|
||||||
|
'id' => 'general_start_date',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
'name' => 'Start Date',
|
'name' => 'Start Date',
|
||||||
'group' => 'general',
|
'group' => 'general',
|
||||||
'key' => 'general.start_date',
|
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
'description' => 'The date your VA started',
|
'description' => 'The date your VA started',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'id' => 'general_admin_email',
|
||||||
'order' => 2,
|
'order' => 2,
|
||||||
'name' => 'Admin Email',
|
'name' => 'Admin Email',
|
||||||
'group' => 'general',
|
'group' => 'general',
|
||||||
'key' => 'general.admin_email',
|
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'description' => 'Email where notices, etc are sent',
|
'description' => 'Email where notices, etc are sent',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'id' => 'general_currency',
|
||||||
'order' => 3,
|
'order' => 3,
|
||||||
'name' => 'Currency to Use',
|
'name' => 'Currency to Use',
|
||||||
'group' => 'general',
|
'group' => 'general',
|
||||||
'key' => 'general.currency',
|
|
||||||
'value' => 'dollar',
|
'value' => 'dollar',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble',
|
'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble',
|
||||||
'description' => 'Currency to show in the interface',
|
'description' => 'Currency to show in the interface',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'id' => 'flight_only_flights_from_current',
|
||||||
'order' => 10,
|
'order' => 10,
|
||||||
'name' => 'Flights from Current',
|
'name' => 'Flights from Current',
|
||||||
'group' => 'flights',
|
'group' => 'flights',
|
||||||
'key' => 'flights.only_flights_from_current',
|
|
||||||
'value' => true,
|
'value' => true,
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Only allow flights from current location',
|
'description' => 'Only allow flights from current location',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'id' => 'bids_disable_flight_on_bid',
|
||||||
'order' => 20,
|
'order' => 20,
|
||||||
'name' => 'Disable flight on bid',
|
'name' => 'Disable flight on bid',
|
||||||
'group' => 'bids',
|
'group' => 'bids',
|
||||||
'key' => 'bids.disable_flight_on_bid',
|
|
||||||
'value' => true,
|
'value' => true,
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'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',
|
||||||
'order' => 21,
|
'order' => 21,
|
||||||
'name' => 'Allow multiple bids',
|
'name' => 'Allow multiple bids',
|
||||||
'group' => 'bids',
|
'group' => 'bids',
|
||||||
'key' => 'bids.allow_multiple_bids',
|
|
||||||
'value' => true,
|
'value' => true,
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Whether or not someone can bid on multiple flights',
|
'description' => 'Whether or not someone can bid on multiple flights',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'id' => 'pilots_id_length',
|
||||||
'order' => 30,
|
'order' => 30,
|
||||||
'name' => 'Hide Inactive Pilots',
|
'name' => 'Pilot ID Length',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'key' => 'pilots.hide_inactive',
|
'value' => 4,
|
||||||
'value' => true,
|
'type' => 'int',
|
||||||
'type' => 'boolean',
|
'description' => 'The length of a pilot\'s ID',
|
||||||
'description' => 'Don\'t show inactive pilots in the public view',
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'id' => 'pilot_auto_accept',
|
||||||
'order' => 31,
|
'order' => 31,
|
||||||
'name' => 'Auto Accept New Pilot',
|
'name' => 'Auto Accept New Pilot',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'key' => 'pilot.auto_accept',
|
|
||||||
'value' => true,
|
'value' => true,
|
||||||
'type' => 'boolean',
|
'type' => 'boolean',
|
||||||
'description' => 'Automatically accept a pilot when they register',
|
'description' => 'Automatically accept a pilot when they register',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'order' => 32,
|
'id' => 'pilot_auto_leave_days',
|
||||||
'name' => 'Pilot ID Length',
|
'order' => 31,
|
||||||
|
'name' => 'Pilot to ON LEAVE days',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'key' => 'pilots.id_length',
|
'value' => 30,
|
||||||
'value' => 4,
|
|
||||||
'type' => 'int',
|
'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',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace App\Listeners;
|
|||||||
use Log;
|
use Log;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
use App\Events\UserRegistered;
|
||||||
use App\Models\Enums\UserState;
|
use App\Models\Enums\UserState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +40,8 @@ class NotificationEventListener
|
|||||||
|
|
||||||
# First send the admin a notification
|
# First send the admin a notification
|
||||||
$admin_email = setting('general.admin_email');
|
$admin_email = setting('general.admin_email');
|
||||||
|
Log::info('Sending admin notification email to "'.$admin_email.'"');
|
||||||
|
|
||||||
if (!empty($admin_email)) {
|
if (!empty($admin_email)) {
|
||||||
$email = new \App\Mail\Admin\UserRegistered($event->user);
|
$email = new \App\Mail\Admin\UserRegistered($event->user);
|
||||||
Mail::to($admin_email)->send($email);
|
Mail::to($admin_email)->send($email);
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: nshahzad
|
|
||||||
* Date: 12/9/17
|
|
||||||
* Time: 6:24 PM
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
class Setting extends BaseModel
|
class Setting extends BaseModel
|
||||||
{
|
{
|
||||||
public $table = 'settings';
|
public $table = 'settings';
|
||||||
|
public $incrementing = false;
|
||||||
|
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
'name',
|
'name',
|
||||||
@ -22,4 +17,18 @@ class Setting extends BaseModel
|
|||||||
'description',
|
'description',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure any dots are replaced with underscores
|
||||||
|
*/
|
||||||
|
static::creating(function (Setting $model) {
|
||||||
|
if (!empty($model->id)) {
|
||||||
|
$model->id = str_replace('.', '_', strtolower($model->id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ class SettingRepository extends BaseRepository implements CacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function retrieve($key)
|
public function retrieve($key)
|
||||||
{
|
{
|
||||||
$key = strtolower($key);
|
$key = str_replace('.', '_', strtolower($key));
|
||||||
$setting = $this->findWhere(['key' => $key], ['type', 'value'])->first();
|
$setting = $this->findWhere(['id' => $key], ['type', 'value'])->first();
|
||||||
|
|
||||||
if(!$setting) {
|
if(!$setting) {
|
||||||
return null;
|
return null;
|
||||||
@ -46,8 +46,12 @@ class SettingRepository extends BaseRepository implements CacheableInterface
|
|||||||
break;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
case 'integer':
|
case 'integer':
|
||||||
|
case 'number':
|
||||||
return (int) $setting->value;
|
return (int) $setting->value;
|
||||||
break;
|
break;
|
||||||
|
case 'float':
|
||||||
|
return (float) $setting->value;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return $setting->value;
|
return $setting->value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user