belongsTo('App\Models\Account'); } public function ticket_master() { return $this->hasOne('App\Models\User', 'id', 'ticket_master_id'); } public function max_file_sizes() { $utils = new Utils(); return $utils->getMaxFileUploadSizes(); } public static function checkUniqueLocalPart($localPart, Account $account) { if (config('ninja.multi_db_enabled')) { $result = LookupAccount::where('support_email_local_part', '=', $localPart) ->where('account_key', '!=', $account->account_key)->get(); } else { $result = AccountTicketSettings::where('support_email_local_part', '=', $localPart) ->where('account_id', '!=', $account->id)->get(); } if(count($result) == 0) return false; else return true; } } AccountTicketSettings::updating(function (AccountTicketSettings $accountTicketSettings) { $dirty = $accountTicketSettings->getDirty(); if (array_key_exists('support_email_local_part', $dirty)) { LookupAccount::updateSupportLocalPart($accountTicketSettings->account->account_key, $dirty['support_email_local_part']); } });