Fixes for archived invoice not emailing

This commit is contained in:
David Bomba 2021-02-26 22:20:17 +11:00
parent 4b3c7ec771
commit cc883f0926
3 changed files with 8 additions and 4 deletions

View File

@ -39,9 +39,9 @@ class StoreUserRequest extends Request
$rules['last_name'] = 'required|string|max:100'; $rules['last_name'] = 'required|string|max:100';
if (config('ninja.db.multi_db_enabled')) { if (config('ninja.db.multi_db_enabled')) {
$rules['email'] = ['email', new ValidUserForCompany(), Rule::unique('users')]; $rules['email'] = ['email', new ValidUserForCompany(), Rule::unique('users')->ignore($this->input('company_user.account.id'), 'account_id')];
} else { } else {
$rules['email'] = ['email',Rule::unique('users')]; $rules['email'] = ['email',Rule::unique('users')->ignore($this->input('company_user.account.id'), 'account_id')];
} }
@ -56,6 +56,10 @@ class StoreUserRequest extends Request
{ {
$input = $this->all(); $input = $this->all();
nlog($this->input('company_user.account'));
// nlog($this->input('company_user.account.id'));
// nlog($this->input('company_user.account.id'));
if (isset($input['company_user'])) { if (isset($input['company_user'])) {
if (! isset($input['company_user']['is_admin'])) { if (! isset($input['company_user']['is_admin'])) {
$input['company_user']['is_admin'] = false; $input['company_user']['is_admin'] = false;

View File

@ -26,7 +26,7 @@ class ValidUserForCompany implements Rule
*/ */
public function passes($attribute, $value) public function passes($attribute, $value)
{ {
return MultiDB::checkUserAndCompanyCoExist($value, auth()->user()->company()->company_key); return MultiDB::checkUserAndCompanyCoExist($value, auth()->user()->company()->company_key, auth()->user()->company()->id);
} }
/** /**

View File

@ -78,7 +78,7 @@ class TemplateEngine
{ {
if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) { if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) {
$class = 'App\Models\\'.ucfirst($this->entity); $class = 'App\Models\\'.ucfirst($this->entity);
$this->entity_obj = $class::whereId($this->decodePrimaryKey($this->entity_id))->company()->first(); $this->entity_obj = $class::withTrashed()->where('id', $this->decodePrimaryKey($this->entity_id))->company()->first();
} else { } else {
$this->mockEntity(); $this->mockEntity();
} }