From 05b03df6001a34a5d25f2a31bae09c945e96f1d3 Mon Sep 17 00:00:00 2001 From: Juho Taipale Date: Thu, 13 Sep 2018 08:49:50 +0300 Subject: [PATCH] Fix for issue #6165 (#6168) * Fix problem when using ValidatingTrait * Checking that email alerts are enabled when trying to send expected check-in alerts (fix for issue #6169) --- .../Commands/SendExpectedCheckinAlerts.php | 7 +------ app/Models/CustomField.php | 20 +++++++++++++++---- app/Models/CustomFieldset.php | 11 +++++++--- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/app/Console/Commands/SendExpectedCheckinAlerts.php b/app/Console/Commands/SendExpectedCheckinAlerts.php index a78f0e1ae3..d0d3ee1550 100644 --- a/app/Console/Commands/SendExpectedCheckinAlerts.php +++ b/app/Console/Commands/SendExpectedCheckinAlerts.php @@ -57,17 +57,12 @@ class SendExpectedCheckinAlerts extends Command } } - // Send a rollup to the admin, if settings dictate $recipient = new \App\Models\Recipients\AlertRecipient(); - if (($assets) && ($assets->count() > 0) && ($settings->alert_email!='')) { + if (($assets) && ($assets->count() > 0) && ($settings->alerts_enabled && $settings->alert_email != '')) { $recipient->notify(new ExpectedCheckinAdminNotification($assets)); } - - - - } } diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index 390c6500b8..0d2565db16 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -12,9 +12,14 @@ use Illuminate\Validation\Rule; class CustomField extends Model { - use ValidatingTrait, UniqueUndeletedTrait; - public $guarded=["id"]; - public static $PredefinedFormats=[ + use ValidatingTrait, + UniqueUndeletedTrait; + + public $guarded = [ + "id" + ]; + + public static $PredefinedFormats = [ "ANY" => "", "CUSTOM REGEX" => "", "ALPHA" => "alpha", @@ -31,6 +36,14 @@ class CustomField extends Model "BOOLEAN" => "boolean", ]; + /** + * Validation rules. + * At least empty array must be provided if using ValidatingTrait. + * + * @var array + */ + protected $rules = []; + /** * The attributes that are mass assignable. * @@ -57,7 +70,6 @@ class CustomField extends Model */ public static $table_name = "assets"; - /** * Convert the custom field's name property to a db-safe string. * diff --git a/app/Models/CustomFieldset.php b/app/Models/CustomFieldset.php index e25248f2c7..9b83051cbc 100644 --- a/app/Models/CustomFieldset.php +++ b/app/Models/CustomFieldset.php @@ -7,10 +7,16 @@ use Watson\Validating\ValidatingTrait; class CustomFieldset extends Model { + use ValidatingTrait; + protected $guarded=["id"]; - public $rules=[ - "name" => "required|unique:custom_fieldsets" + /** + * Validation rules + * @var array + */ + protected $rules = [ + "name" => "required|unique:custom_fieldsets" ]; /** @@ -21,7 +27,6 @@ class CustomFieldset extends Model * @var boolean */ protected $injectUniqueIdentifier = true; - use ValidatingTrait; /**