diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 348be085a873..11b8a9de03d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,6 +48,11 @@ jobs: run: | sudo rm -rf bootstrap/cache/* sudo rm -rf node_modules + - name: Prune Git History + run: | + sudo git gc + sudo git gc --aggressive + sudo git prune - name: Build project # This would actually build your project, using zip for an example artifact run: | zip -r ./invoiceninja.zip .* -x "../*" diff --git a/app/Http/Requests/User/StoreUserRequest.php b/app/Http/Requests/User/StoreUserRequest.php index 0786dda42de9..512994be8b3e 100644 --- a/app/Http/Requests/User/StoreUserRequest.php +++ b/app/Http/Requests/User/StoreUserRequest.php @@ -39,9 +39,9 @@ class StoreUserRequest extends Request $rules['last_name'] = 'required|string|max:100'; 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 { - $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(); +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']['is_admin'])) { $input['company_user']['is_admin'] = false; diff --git a/app/Http/ValidationRules/ValidUserForCompany.php b/app/Http/ValidationRules/ValidUserForCompany.php index d09b5760aa40..967ca56591d7 100644 --- a/app/Http/ValidationRules/ValidUserForCompany.php +++ b/app/Http/ValidationRules/ValidUserForCompany.php @@ -26,7 +26,7 @@ class ValidUserForCompany implements Rule */ 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); } /** diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 08895dab6741..4d29271c360b 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -214,7 +214,7 @@ class Import implements ShouldQueue // if($check_data['status'] == 'errors') // throw new ProcessingMigrationArchiveFailed(implode("\n", $check_data)); - Mail::to($this->user) + Mail::to($this->user->email, $this->user->name()) ->send(new MigrationCompleted($this->company, implode("
",$check_data))); /*After a migration first some basic jobs to ensure the system is up to date*/ diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 8f942d0ea15b..aecb446a18a5 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -152,6 +152,11 @@ class Credit extends BaseModel return $this->hasMany(CreditInvitation::class); } + public function project() + { + return $this->belongsTo(Project::class)->withTrashed(); + } + /** * The invoice which the credit has been created from. */ diff --git a/app/Models/Quote.php b/app/Models/Quote.php index d23451290ffd..9038c6ef3b62 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -149,6 +149,11 @@ class Quote extends BaseModel return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed(); } + public function project() + { + return $this->belongsTo(Project::class)->withTrashed(); + } + public function invitations() { return $this->hasMany(QuoteInvitation::class); diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 42ece6503403..6bba8fc6242d 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -167,6 +167,11 @@ class RecurringInvoice extends BaseModel return $this->belongsTo(Client::class)->withTrashed(); } + public function project() + { + return $this->belongsTo(Project::class)->withTrashed(); + } + public function user() { return $this->belongsTo(User::class)->withTrashed(); diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index d5501ef87411..fb9b863e0949 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -78,7 +78,7 @@ class TemplateEngine { if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) { $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 { $this->mockEntity(); }