diff --git a/app/Console/Commands/CreateAccount.php b/app/Console/Commands/CreateAccount.php index 460dbe72d36b..90613083d2cb 100644 --- a/app/Console/Commands/CreateAccount.php +++ b/app/Console/Commands/CreateAccount.php @@ -131,9 +131,9 @@ class CreateAccount extends Command 'settings' => null, ]); - CreateCompanyPaymentTerms::dispatchNow($company, $user); - CreateCompanyTaskStatuses::dispatchNow($company, $user); - VersionCheck::dispatchNow(); + CreateCompanyPaymentTerms::dispatchSync($company, $user); + CreateCompanyTaskStatuses::dispatchSync($company, $user); + VersionCheck::dispatchSync(); } private function warmCache() diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 7b72ce52c130..7d80034b857e 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -188,7 +188,7 @@ class CreateSingleAccount extends Command $this->createClient($company, $user); } - CreateCompanyTaskStatuses::dispatchNow($company, $user); + CreateCompanyTaskStatuses::dispatchSync($company, $user); for ($x = 0; $x < $this->count; $x++) { $client = $company->clients->random(); diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index d667278877ee..38fb577a1b38 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -112,9 +112,9 @@ class DemoMode extends Command $this->info('Seeding Random Data'); $this->createSmallAccount(); - VersionCheck::dispatchNow(); + VersionCheck::dispatchSync(); - CompanySizeCheck::dispatchNow(); + CompanySizeCheck::dispatchSync(); } private function createSmallAccount() @@ -164,8 +164,8 @@ class DemoMode extends Command ]); } - CreateCompanyPaymentTerms::dispatchNow($company, $user); - CreateCompanyTaskStatuses::dispatchNow($company, $user); + CreateCompanyPaymentTerms::dispatchSync($company, $user); + CreateCompanyTaskStatuses::dispatchSync($company, $user); $company_token = new CompanyToken; $company_token->user_id = $user->id; diff --git a/app/Console/Commands/HostedUsers.php b/app/Console/Commands/HostedUsers.php index 7fc670ce1249..ec076dc86b26 100644 --- a/app/Console/Commands/HostedUsers.php +++ b/app/Console/Commands/HostedUsers.php @@ -43,13 +43,13 @@ class HostedUsers extends Command { Company::on('db-ninja-01')->each(function ($company) { if (Ninja::isHosted()) { - \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company); + \Modules\Admin\Jobs\Account\NinjaUser::dispatchSync([], $company); } }); Company::on('db-ninja-02')->each(function ($company) { if (Ninja::isHosted()) { - \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company); + \Modules\Admin\Jobs\Account\NinjaUser::dispatchSync([], $company); } }); } diff --git a/app/Console/Commands/RecurringCommand.php b/app/Console/Commands/RecurringCommand.php index 325100d82a08..628a09b8f548 100644 --- a/app/Console/Commands/RecurringCommand.php +++ b/app/Console/Commands/RecurringCommand.php @@ -47,6 +47,6 @@ class RecurringCommand extends Command */ public function handle() { - RecurringInvoicesCron::dispatchNow(); + RecurringInvoicesCron::dispatchSync(); } } diff --git a/app/Console/Commands/SendTestEmails.php b/app/Console/Commands/SendTestEmails.php index d8b27410caa4..924fb7256608 100644 --- a/app/Console/Commands/SendTestEmails.php +++ b/app/Console/Commands/SendTestEmails.php @@ -96,6 +96,6 @@ class SendTestEmails extends Command $nmo->settings = $user->account->companies()->first()->settings; $nmo->to_user = $user; - NinjaMailerJob::dispatchNow($nmo); + NinjaMailerJob::dispatchSync($nmo); } } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 7f512abf4a49..48dddbb64428 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -143,8 +143,7 @@ class AccountController extends BaseController */ public function store(CreateAccountRequest $request) { - $account = CreateAccount::dispatchNow($request->all(), $request->getClientIp()); - + $account = (new CreateAccount($request->all(), $request->getClientIp()))->handle(); if (! ($account instanceof Account)) { return $account; } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 7626056d13eb..a6a2baf84a19 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -186,13 +186,13 @@ class LoginController extends BaseController if ($user->google_2fa_secret && $request->has('one_time_password')) { $google2fa = new Google2FA(); - if (strlen($request->input('one_time_password')) == 0 || ! $google2fa->verifyKey(decrypt($user->google_2fa_secret), $request->input('one_time_password'))) { + if (strlen($request->input('one_time_password')) == 0 || !$google2fa->verifyKey(decrypt($user->google_2fa_secret), $request->input('one_time_password'))) { return response() - ->json(['message' => ctrans('texts.invalid_one_time_password')], 401) - ->header('X-App-Version', config('ninja.app_version')) - ->header('X-Api-Version', config('ninja.minimum_client_version')); + ->json(['message' => ctrans('texts.invalid_one_time_password')], 401) + ->header('X-App-Version', config('ninja.app_version')) + ->header('X-Api-Version', config('ninja.minimum_client_version')); } - } elseif ($user->google_2fa_secret && ! $request->has('one_time_password')) { + } elseif ($user->google_2fa_secret && !$request->has('one_time_password')) { return response() ->json(['message' => ctrans('texts.invalid_one_time_password')], 401) ->header('X-App-Version', config('ninja.app_version')) @@ -200,7 +200,7 @@ class LoginController extends BaseController } /* If for some reason we lose state on the default company ie. a company is deleted - always make sure we can default to a company*/ - if (! $user->account->default_company) { + if (!$user->account->default_company) { $account = $user->account; $account->default_company_id = $user->companies->first()->id; $account->save(); @@ -214,7 +214,7 @@ class LoginController extends BaseController } /*On the hosted platform, only owners can login for free/pro accounts*/ - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $user->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !$user->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -293,7 +293,7 @@ class LoginController extends BaseController $cu->first()->account->companies->each(function ($company) use ($cu, $request) { if ($company->tokens()->where('is_system', true)->count() == 0) { - CreateCompanyToken::dispatchNow($company, $cu->first()->user, $request->server('HTTP_USER_AGENT')); + CreateCompanyToken::dispatchSync($company, $cu->first()->user, $request->server('HTTP_USER_AGENT')); } }); @@ -301,7 +301,7 @@ class LoginController extends BaseController $cu->where('company_id', $company_token->company_id); } - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $cu->first()->user->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !$cu->first()->user->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -371,7 +371,7 @@ class LoginController extends BaseController 'oauth_provider_id' => $provider, ]; if ($existing_user = MultiDB::hasUser($query)) { - if (! $existing_user->account) { + if (!$existing_user->account) { return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); } @@ -383,7 +383,7 @@ class LoginController extends BaseController return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); } - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $existing_user->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !$existing_user->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -391,7 +391,7 @@ class LoginController extends BaseController } //If this is a result user/email combo - lets add their OAuth details details if ($existing_login_user = MultiDB::hasUser(['email' => $user->email])) { - if (! $existing_login_user->account) { + if (!$existing_login_user->account) { return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); } @@ -408,7 +408,7 @@ class LoginController extends BaseController return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); } - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $existing_login_user->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !$existing_login_user->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -427,7 +427,7 @@ class LoginController extends BaseController MultiDB::setDefaultDatabase(); - $account = CreateAccount::dispatchNow($new_account, request()->getClientIp()); + $account = (new CreateAccount($new_account, request()->getClientIp()))->handle(); Auth::login($account->default_company->owner(), true); auth()->user()->email_verified_at = now(); @@ -439,7 +439,7 @@ class LoginController extends BaseController return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); } - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! auth()->user()->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !auth()->user()->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -475,8 +475,8 @@ class LoginController extends BaseController if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) { auth()->user()->companies->each(function ($company) { - if (! CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->exists()) { - CreateCompanyToken::dispatchNow($company, auth()->user(), 'Google_O_Auth'); + if (!CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->exists()) { + CreateCompanyToken::dispatchSync($company, auth()->user(), 'Google_O_Auth'); } }); } @@ -498,8 +498,8 @@ class LoginController extends BaseController $graph->setAccessToken($accessToken); $user = $graph->createRequest('GET', '/me') - ->setReturnType(Model\User::class) - ->execute(); + ->setReturnType(Model\User::class) + ->execute(); if ($user) { $account = request()->input('account'); @@ -507,11 +507,11 @@ class LoginController extends BaseController $query = [ 'oauth_user_id' => $user->getId(), - 'oauth_provider_id'=> 'microsoft', + 'oauth_provider_id' => 'microsoft', ]; if ($existing_user = MultiDB::hasUser($query)) { - if (! $existing_user->account) { + if (!$existing_user->account) { return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); } @@ -520,7 +520,7 @@ class LoginController extends BaseController //If this is a result user/email combo - lets add their OAuth details details if ($existing_login_user = MultiDB::hasUser(['email' => $email])) { - if (! $existing_login_user->account) { + if (!$existing_login_user->account) { return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); } @@ -553,7 +553,7 @@ class LoginController extends BaseController return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); } - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $existing_user->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !$existing_user->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -564,7 +564,7 @@ class LoginController extends BaseController { auth()->user()->update([ 'oauth_user_id' => $oauth_user_id, - 'oauth_provider_id'=> $provider, + 'oauth_provider_id' => $provider, ]); $cu = $this->hydrateCompanyUser(); @@ -573,7 +573,7 @@ class LoginController extends BaseController return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); } - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! auth()->user()->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !auth()->user()->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -591,11 +591,11 @@ class LoginController extends BaseController if (is_array($user)) { $query = [ 'oauth_user_id' => $google->harvestSubField($user), - 'oauth_provider_id'=> 'google', + 'oauth_provider_id' => 'google', ]; if ($existing_user = MultiDB::hasUser($query)) { - if (! $existing_user->account) { + if (!$existing_user->account) { return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); } @@ -604,7 +604,7 @@ class LoginController extends BaseController //If this is a result user/email combo - lets add their OAuth details details if ($existing_login_user = MultiDB::hasUser(['email' => $google->harvestEmail($user)])) { - if (! $existing_login_user->account) { + if (!$existing_login_user->account) { return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); } @@ -618,7 +618,7 @@ class LoginController extends BaseController //check the user doesn't already exist in some form if ($existing_login_user = MultiDB::hasUser(['email' => $google->harvestEmail($user)])) { - if (! $existing_login_user->account) { + if (!$existing_login_user->account) { return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); } @@ -643,18 +643,17 @@ class LoginController extends BaseController } return response() - ->json(['message' => ctrans('texts.invalid_credentials')], 401) - ->header('X-App-Version', config('ninja.app_version')) - ->header('X-Api-Version', config('ninja.minimum_client_version')); + ->json(['message' => ctrans('texts.invalid_credentials')], 401) + ->header('X-App-Version', config('ninja.app_version')) + ->header('X-Api-Version', config('ninja.minimum_client_version')); } private function createNewAccount($new_account) { MultiDB::setDefaultDatabase(); - $account = CreateAccount::dispatchNow($new_account, request()->getClientIp()); - - if (! $account instanceof Account) { + $account = (new CreateAccount($new_account, request()->getClientIp()))->handle(); + if (!$account instanceof Account) { return $account; } @@ -668,7 +667,7 @@ class LoginController extends BaseController return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); } - if (Ninja::isHosted() && ! $cu->first()->is_owner && ! auth()->user()->account->isEnterpriseClient()) { + if (Ninja::isHosted() && !$cu->first()->is_owner && !auth()->user()->account->isEnterpriseClient()) { return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); } @@ -683,18 +682,18 @@ class LoginController extends BaseController if ($provider == 'google') { $scopes = ['https://www.googleapis.com/auth/gmail.send', 'email', 'profile', 'openid']; - $parameters = ['access_type' => 'offline', 'prompt' => 'consent select_account', 'redirect_uri' => config('ninja.app_url').'/auth/google']; + $parameters = ['access_type' => 'offline', 'prompt' => 'consent select_account', 'redirect_uri' => config('ninja.app_url') . '/auth/google']; } if ($provider == 'microsoft') { $scopes = ['email', 'Mail.ReadWrite', 'Mail.Send', 'offline_access', 'profile', 'User.Read openid']; - $parameters = ['response_type' => 'code', 'redirect_uri' => config('ninja.app_url').'/auth/microsoft']; + $parameters = ['response_type' => 'code', 'redirect_uri' => config('ninja.app_url') . '/auth/microsoft']; } if (request()->has('code')) { return $this->handleProviderCallback($provider); } else { - if (! in_array($provider, ['google', 'microsoft'])) { + if (!in_array($provider, ['google', 'microsoft'])) { return abort(400, 'Invalid provider'); } @@ -747,8 +746,8 @@ class LoginController extends BaseController $socialite_user = Socialite::driver($provider)->user(); nlog($socialite_user); - nlog('refresh token '.$socialite_user->accessTokenResponseBody['refresh_token']); - nlog('access token '.$socialite_user->accessTokenResponseBody['access_token']); + nlog('refresh token ' . $socialite_user->accessTokenResponseBody['refresh_token']); + nlog('access token ' . $socialite_user->accessTokenResponseBody['access_token']); $oauth_user_token = $socialite_user->accessTokenResponseBody['access_token']; diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index 4011c1d44a02..e2163487020d 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -197,7 +197,7 @@ class InvitationController extends Controller $file_name = $invitation->{$entity}->numberFormatter().'.pdf'; - $file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db); + $file = (new CreateRawPdf($invitation, $invitation->company->db))->handle(); $headers = ['Content-Type' => 'application/pdf']; diff --git a/app/Http/Controllers/ClientPortal/ProfileController.php b/app/Http/Controllers/ClientPortal/ProfileController.php index 193eb9fe47f1..5fa5f14c1de2 100644 --- a/app/Http/Controllers/ClientPortal/ProfileController.php +++ b/app/Http/Controllers/ClientPortal/ProfileController.php @@ -63,7 +63,7 @@ class ProfileController extends Controller //update avatar if needed if ($request->file('logo')) { - $path = UploadAvatar::dispatchNow($request->file('logo'), auth()->user()->client->client_hash); + $path = (new UploadAvatar($request->file('logo'), auth()->user()->client->client_hash))->handle(); if ($path) { $client->logo = $path; diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 0be886c5797b..19cc8a6657f5 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -211,10 +211,9 @@ class CompanyController extends BaseController { $this->forced_includes = ['company_user']; - $company = CreateCompany::dispatchNow($request->all(), auth()->user()->company()->account); - - CreateCompanyPaymentTerms::dispatchNow($company, auth()->user()); - CreateCompanyTaskStatuses::dispatchNow($company, auth()->user()); + $company = (new CreateCompany($request->all(), auth()->user()->company()->account))->handle(); + CreateCompanyPaymentTerms::dispatchSync($company, auth()->user()); + CreateCompanyTaskStatuses::dispatchSync($company, auth()->user()); $company = $this->company_repo->save($request->all(), $company); @@ -244,8 +243,7 @@ class CompanyController extends BaseController */ $user_agent = request()->has('token_name') ? request()->input('token_name') : request()->server('HTTP_USER_AGENT'); - $company_token = CreateCompanyToken::dispatchNow($company, auth()->user(), $user_agent); - + $company_token = (new CreateCompanyToken($company, auth()->user(), $user_agent))->handle(); $this->entity_transformer = CompanyUserTransformer::class; $this->entity_type = CompanyUser::class; diff --git a/app/Http/Controllers/HostedMigrationController.php b/app/Http/Controllers/HostedMigrationController.php index a9cc3bb6ae64..e8a60452080e 100644 --- a/app/Http/Controllers/HostedMigrationController.php +++ b/app/Http/Controllers/HostedMigrationController.php @@ -36,7 +36,7 @@ class HostedMigrationController extends Controller return response()->json(['error' => 'This user is not able to perform a migration. Please contact us at contact@invoiceninja.com to discuss.'], 401); } - $account = CreateAccount::dispatchNow($request->all(), $request->getClientIp()); + $account = (new CreateAccount($request->all(), $request->getClientIp()))->handle(); $account->hosted_client_count = 100; $account->hosted_company_count = 10; $account->save(); @@ -44,8 +44,8 @@ class HostedMigrationController extends Controller $company = $account->companies->first(); $company_token = CompanyToken::where('user_id', auth()->user()->id) - ->where('company_id', $company->id) - ->first(); + ->where('company_id', $company->id) + ->first(); return response()->json(['token' => $company_token->token], 200); } @@ -64,7 +64,7 @@ class HostedMigrationController extends Controller $forward_url = $company->domain(); - $billing_transferred = \Modules\Admin\Jobs\Account\TransferAccountPlan::dispatchNow($input); + $billing_transferred = (new \Modules\Admin\Jobs\Account\TransferAccountPlan($input))->handle(); return response()->json(['forward_url' => $forward_url, 'billing_transferred' => $billing_transferred], 200); } diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 394b55215e5c..9097673733be 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -170,8 +170,8 @@ class PreviewController extends BaseController } //else - $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); + $file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle(); return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); } @@ -295,7 +295,7 @@ class PreviewController extends BaseController return $pdf; } - $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), $company); + $file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle(); if (Ninja::isHosted()) { LightLogs::create(new LivePreview()) @@ -369,7 +369,7 @@ class PreviewController extends BaseController return $pdf; } - $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); + $file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle(); $response = Response::make($file_path, 200); $response->header('Content-Type', 'application/pdf'); @@ -464,7 +464,8 @@ class PreviewController extends BaseController return $pdf; } - $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); + + $file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle(); $response = Response::make($file_path, 200); $response->header('Content-Type', 'application/pdf'); diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 7e1c26f165bb..36493d48f11b 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -145,10 +145,10 @@ class SetupController extends Controller /* Create the first account. */ if (Account::count() == 0) { - CreateAccount::dispatchNow($request->all(), $request->getClientIp()); + CreateAccount::dispatchSync($request->all(), $request->getClientIp()); } - VersionCheck::dispatchNow(); + VersionCheck::dispatchSync(); $this->buildCache(true); @@ -316,7 +316,7 @@ class SetupController extends Controller $this->buildCache(true); - SchedulerCheck::dispatchNow(); + SchedulerCheck::dispatchSync(); return redirect('/'); } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 2b51784059e0..3c8f2cd76ba0 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -208,7 +208,7 @@ class UserController extends BaseController $user_agent = request()->input('token_name') ?: request()->server('HTTP_USER_AGENT'); - $ct = CreateCompanyToken::dispatchNow($company, $user, $user_agent); + $ct = (new CreateCompanyToken($company, $user, $user_agent))->handle(); event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index c0543e0d98c6..901d2287c82a 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -463,7 +463,7 @@ class BillingPortalPurchase extends Component $mailer->settings = $this->subscription->company->settings; $mailer->to_user = $contact; - NinjaMailerJob::dispatchNow($mailer); + NinjaMailerJob::dispatchSync($mailer); $this->steps['passwordless_login_sent'] = true; $this->passwordless_login_btn = false; diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index 64c3687a8722..ad1637ee7bdc 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -90,15 +90,15 @@ class CreateAccount $sp794f3f->save(); - $sp035a66 = CreateCompany::dispatchNow($this->request, $sp794f3f); + $sp035a66 = (new CreateCompany($this->request,$sp794f3f))->handle(); $sp035a66->load('account'); $sp794f3f->default_company_id = $sp035a66->id; $sp794f3f->save(); - $spaa9f78 = CreateUser::dispatchNow($this->request, $sp794f3f, $sp035a66, true); + $spaa9f78 = (new CreateUser($this->request, $sp794f3f, $sp035a66, true))->handle(); - CreateCompanyPaymentTerms::dispatchNow($sp035a66, $spaa9f78); - CreateCompanyTaskStatuses::dispatchNow($sp035a66, $spaa9f78); + CreateCompanyPaymentTerms::dispatchSync($sp035a66, $spaa9f78); + CreateCompanyTaskStatuses::dispatchSync($sp035a66, $spaa9f78); if ($spaa9f78) { auth()->login($spaa9f78, false); @@ -108,8 +108,7 @@ class CreateAccount $this->setLoginCache($spaa9f78); $spafe62e = isset($this->request['token_name']) ? $this->request['token_name'] : request()->server('HTTP_USER_AGENT'); - $sp2d97e8 = CreateCompanyToken::dispatchNow($sp035a66, $spaa9f78, $spafe62e); - + $sp2d97e8 = (new CreateCompanyToken($sp035a66, $spaa9f78, $spafe62e))->handle(); if ($spaa9f78) { event(new AccountCreated($spaa9f78, $sp035a66, Ninja::eventVars())); } diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index 0695eae34d42..d6698d263ed1 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -282,7 +282,7 @@ class CompanyImport implements ShouldQueue $nmo->company = $_company; $nmo->settings = $_company->settings; $nmo->to_user = $_company->owner(); - NinjaMailerJob::dispatchNow($nmo); + NinjaMailerJob::dispatchSync($nmo); } catch (\Exception $e) { info($e->getMessage()); } @@ -1441,6 +1441,6 @@ class CompanyImport implements ShouldQueue $nmo->company = $this->company; $nmo->settings = $this->company->settings; $nmo->to_user = $this->company->owner(); - NinjaMailerJob::dispatchNow($nmo); + NinjaMailerJob::dispatchSync($nmo); } } diff --git a/app/Jobs/Credit/ZipCredits.php b/app/Jobs/Credit/ZipCredits.php index f4c1ff8175e9..ec851529a57b 100644 --- a/app/Jobs/Credit/ZipCredits.php +++ b/app/Jobs/Credit/ZipCredits.php @@ -80,7 +80,7 @@ class ZipCredits implements ShouldQueue $path = $this->credits->first()->client->quote_filepath($invitation); $this->credits->each(function ($credit) { - CreateEntityPdf::dispatchNow($credit->invitations()->first()); + CreateEntityPdf::dispatchSync($credit->invitations()->first()); }); try { diff --git a/app/Jobs/Cron/RecurringInvoicesCron.php b/app/Jobs/Cron/RecurringInvoicesCron.php index cadadbcba171..5584f5c18628 100644 --- a/app/Jobs/Cron/RecurringInvoicesCron.php +++ b/app/Jobs/Cron/RecurringInvoicesCron.php @@ -74,7 +74,7 @@ class RecurringInvoicesCron } try { - SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db); + SendRecurring::dispatchSync($recurring_invoice, $recurring_invoice->company->db); } catch (\Exception $e) { nlog("Unable to sending recurring invoice {$recurring_invoice->id} ".$e->getMessage()); } @@ -114,7 +114,7 @@ class RecurringInvoicesCron } try { - SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db); + SendRecurring::dispatchSync($recurring_invoice, $recurring_invoice->company->db); } catch (\Exception $e) { nlog("Unable to sending recurring invoice {$recurring_invoice->id} ".$e->getMessage()); } diff --git a/app/Jobs/Entity/EmailEntity.php b/app/Jobs/Entity/EmailEntity.php index 6e5350b64c18..e47375270e9c 100644 --- a/app/Jobs/Entity/EmailEntity.php +++ b/app/Jobs/Entity/EmailEntity.php @@ -126,7 +126,7 @@ class EmailEntity implements ShouldQueue $nmo->reminder_template = $this->reminder_template; $nmo->entity = $this->entity; - NinjaMailerJob::dispatchNow($nmo); + NinjaMailerJob::dispatchSync($nmo); } private function resolveEntityString() :string diff --git a/app/Jobs/Invoice/ZipInvoices.php b/app/Jobs/Invoice/ZipInvoices.php index 70d1d7be843f..e3ba20013408 100644 --- a/app/Jobs/Invoice/ZipInvoices.php +++ b/app/Jobs/Invoice/ZipInvoices.php @@ -80,7 +80,7 @@ class ZipInvoices implements ShouldQueue $path = $this->invoices->first()->client->invoice_filepath($invitation); $this->invoices->each(function ($invoice) { - CreateEntityPdf::dispatchNow($invoice->invitations()->first()); + CreateEntityPdf::dispatchSync($invoice->invitations()->first()); }); try { diff --git a/app/Jobs/Ninja/CheckDbStatus.php b/app/Jobs/Ninja/CheckDbStatus.php index 82c8633d4f00..8c782fd5ee57 100644 --- a/app/Jobs/Ninja/CheckDbStatus.php +++ b/app/Jobs/Ninja/CheckDbStatus.php @@ -39,7 +39,7 @@ class CheckDbStatus implements ShouldQueue */ public function handle() { - DbStatus::dispatchNow('db-ninja-01', 'db.status.db-ninja-01'); - DbStatus::dispatchNow('db-ninja-02', 'db.status.db-ninja-02'); + DbStatus::dispatchSync('db-ninja-01', 'db.status.db-ninja-01'); + DbStatus::dispatchSync('db-ninja-02', 'db.status.db-ninja-02'); } } diff --git a/app/Jobs/Ninja/SendReminders.php b/app/Jobs/Ninja/SendReminders.php index d6b3bef92d71..d84c04b3631b 100644 --- a/app/Jobs/Ninja/SendReminders.php +++ b/app/Jobs/Ninja/SendReminders.php @@ -214,7 +214,7 @@ class SendReminders implements ShouldQueue if ($this->checkSendSetting($invoice, $template) && $invoice->company->account->hasFeature(Account::FEATURE_EMAIL_TEMPLATES_REMINDERS)) { nlog('firing email'); - EmailEntity::dispatchNow($invitation, $invitation->company, $template); + EmailEntity::dispatchSync($invitation, $invitation->company, $template); } }); diff --git a/app/Jobs/PurchaseOrder/PurchaseOrderEmail.php b/app/Jobs/PurchaseOrder/PurchaseOrderEmail.php index 32444e61ed90..c49154a09208 100644 --- a/app/Jobs/PurchaseOrder/PurchaseOrderEmail.php +++ b/app/Jobs/PurchaseOrder/PurchaseOrderEmail.php @@ -89,7 +89,7 @@ class PurchaseOrderEmail implements ShouldQueue $nmo->reminder_template = 'purchase_order'; $nmo->entity = $invitation->purchase_order; - NinjaMailerJob::dispatchNow($nmo); + NinjaMailerJob::dispatchSync($nmo); }); if ($this->purchase_order->invitations->count() >= 1) { diff --git a/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php b/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php index e6b799b0f567..a440e2c1ccb9 100644 --- a/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php +++ b/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php @@ -82,7 +82,7 @@ class ZipPurchaseOrders implements ShouldQueue $path = $this->purchase_orders->first()->vendor->purchase_order_filepath($invitation); $this->purchase_orders->each(function ($purchase_order) { - CreatePurchaseOrderPdf::dispatchNow($purchase_order->invitations()->first()); + CreatePurchaseOrderPdf::dispatchSync($purchase_order->invitations()->first()); }); try { diff --git a/app/Jobs/Quote/ZipQuotes.php b/app/Jobs/Quote/ZipQuotes.php index 5a2f207b7bba..c8cf24ed1e8d 100644 --- a/app/Jobs/Quote/ZipQuotes.php +++ b/app/Jobs/Quote/ZipQuotes.php @@ -80,7 +80,7 @@ class ZipQuotes implements ShouldQueue $path = $this->quotes->first()->client->quote_filepath($invitation); $this->quotes->each(function ($quote) { - CreateEntityPdf::dispatchNow($quote->invitations()->first()); + CreateEntityPdf::dispatchSync($quote->invitations()->first()); }); try { diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 590f296e598b..d5a73da931fc 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -215,7 +215,7 @@ class Import implements ShouldQueue $data = $array['data']; foreach ($this->available_imports as $import) { - if (! array_key_exists($import, $data)) { + if (!array_key_exists($import, $data)) { info("Resource {$import} is not available for migration."); continue; } @@ -253,7 +253,7 @@ class Import implements ShouldQueue $this->setInitialCompanyLedgerBalances(); // $this->fixClientBalances(); - $check_data = CheckCompanyData::dispatchNow($this->company, md5(time())); + $check_data = (new CheckCompanyData($this->company, md5(time())))->handle(); // if(Ninja::isHosted() && array_key_exists('ninja_tokens', $data)) $this->processNinjaTokens($data['ninja_tokens']); @@ -273,7 +273,7 @@ class Import implements ShouldQueue /*After a migration first some basic jobs to ensure the system is up to date*/ VersionCheck::dispatch(); - info('CompletedπŸš€πŸš€πŸš€πŸš€πŸš€ at '.now()); + info('CompletedπŸš€πŸš€πŸš€πŸš€πŸš€ at ' . now()); unlink($this->file_path); } @@ -327,7 +327,7 @@ class Import implements ShouldQueue }); } - private function processAccount(array $data) :void + private function processAccount(array $data): void { if (array_key_exists('token', $data)) { $this->token = $data['token']; @@ -364,7 +364,7 @@ class Import implements ShouldQueue $data = $this->transformCompanyData($data); if (Ninja::isHosted()) { - if (! MultiDB::checkDomainAvailable($data['subdomain'])) { + if (!MultiDB::checkDomainAvailable($data['subdomain'])) { $data['subdomain'] = MultiDB::randomSubdomainGenerator(); } @@ -426,7 +426,7 @@ class Import implements ShouldQueue $company_repository = null; } - private function parseCustomFields($fields) :array + private function parseCustomFields($fields): array { if (array_key_exists('account1', $fields)) { $fields['company1'] = $fields['account1']; @@ -453,7 +453,7 @@ class Import implements ShouldQueue } foreach ($fields as &$value) { - $value = (string) $value; + $value = (string)$value; } return $fields; @@ -468,7 +468,7 @@ class Import implements ShouldQueue if ($key == 'invoice_design_id' || $key == 'quote_design_id' || $key == 'credit_design_id') { $value = $this->encodePrimaryKey($value); - if (! $value) { + if (!$value) { $value = $this->encodePrimaryKey(1); } } @@ -581,7 +581,7 @@ class Import implements ShouldQueue $user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT'); - CreateCompanyToken::dispatchNow($this->company, $user, $user_agent); + CreateCompanyToken::dispatchSync($this->company, $user, $user_agent); $key = "users_{$resource['id']}"; @@ -605,12 +605,12 @@ class Import implements ShouldQueue $value = trim($value); $model_query = $model::where($column, $value) - ->where('company_id', $this->company->id) - ->withTrashed() - ->exists(); + ->where('company_id', $this->company->id) + ->withTrashed() + ->exists(); if ($model_query) { - return $value.'_'.Str::random(5); + return $value . '_' . Str::random(5); } return $value; @@ -679,13 +679,13 @@ class Import implements ShouldQueue foreach ($resource['contacts'] as $key => $old_contact) { $contact_match = ClientContact::where('contact_key', $old_contact['contact_key']) - ->where('company_id', $this->company->id) - ->where('client_id', $client->id) - ->withTrashed() - ->first(); + ->where('company_id', $this->company->id) + ->where('client_id', $client->id) + ->withTrashed() + ->first(); if ($contact_match) { - $this->ids['client_contacts']['client_contacts_'.$old_contact['id']] = [ + $this->ids['client_contacts']['client_contacts_' . $old_contact['id']] = [ 'old' => $old_contact['id'], 'new' => $contact_match->id, ]; @@ -831,7 +831,7 @@ class Import implements ShouldQueue $product_repository = null; } - private function processRecurringExpenses(array $data) :void + private function processRecurringExpenses(array $data): void { RecurringExpense::unguard(); @@ -893,7 +893,7 @@ class Import implements ShouldQueue $data = null; } - private function processRecurringInvoices(array $data) :void + private function processRecurringInvoices(array $data): void { RecurringInvoice::unguard(); @@ -912,7 +912,7 @@ class Import implements ShouldQueue foreach ($data as $key => $resource) { $modified = $resource; - if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) { + if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) { throw new ResourceDependencyMissing('Processing invoices failed, because of missing dependency - clients.'); } @@ -989,14 +989,14 @@ class Import implements ShouldQueue foreach ($data as $key => $resource) { $modified = $resource; - if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) { + if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) { throw new ResourceDependencyMissing('Processing invoices failed, because of missing dependency - clients.'); } $modified['client_id'] = $this->transformId('clients', $resource['client_id']); - if (array_key_exists('recurring_id', $resource) && ! is_null($resource['recurring_id'])) { - $modified['recurring_id'] = $this->transformId('recurring_invoices', (string) $resource['recurring_id']); + if (array_key_exists('recurring_id', $resource) && !is_null($resource['recurring_id'])) { + $modified['recurring_id'] = $this->transformId('recurring_invoices', (string)$resource['recurring_id']); } $modified['user_id'] = $this->processUserId($resource); @@ -1041,7 +1041,7 @@ class Import implements ShouldQueue /* Prevent edge case where V4 has inserted multiple invitations for a resource for a client contact */ private function deDuplicateInvitations($invitations) { - return array_intersect_key($invitations, array_unique(array_column($invitations, 'client_contact_id'))); + return array_intersect_key($invitations, array_unique(array_column($invitations, 'client_contact_id'))); } private function processCredits(array $data): void @@ -1063,7 +1063,7 @@ class Import implements ShouldQueue foreach ($data as $resource) { $modified = $resource; - if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) { + if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) { throw new ResourceDependencyMissing('Processing credits failed, because of missing dependency - clients.'); } @@ -1127,7 +1127,7 @@ class Import implements ShouldQueue foreach ($data as $resource) { $modified = $resource; - if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) { + if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) { throw new ResourceDependencyMissing('Processing quotes failed, because of missing dependency - clients.'); } @@ -1224,7 +1224,7 @@ class Import implements ShouldQueue foreach ($data as $resource) { $modified = $resource; - if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) { + if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) { throw new ResourceDependencyMissing('Processing payments failed, because of missing dependency - clients.'); } @@ -1297,15 +1297,15 @@ class Import implements ShouldQueue $invoices->each(function ($invoice) use ($payment) { if ($payment->refunded > 0 && in_array($invoice->status_id, [Invoice::STATUS_SENT])) { $invoice->service() - ->updateBalance($payment->refunded) - ->updatePaidToDate($payment->refunded * -1) - ->updateStatus() - ->save(); + ->updateBalance($payment->refunded) + ->updatePaidToDate($payment->refunded * -1) + ->updateStatus() + ->save(); } }); } - private function updatePaymentForStatus($payment, $status_id) :Payment + private function updatePaymentForStatus($payment, $status_id): Payment { // define('PAYMENT_STATUS_PENDING', 1); // define('PAYMENT_STATUS_VOIDED', 2); @@ -1354,12 +1354,12 @@ class Import implements ShouldQueue foreach ($data as $resource) { $modified = $resource; - if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && ! array_key_exists('invoices', $this->ids)) { + if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && !array_key_exists('invoices', $this->ids)) { return; //throw new ResourceDependencyMissing('Processing documents failed, because of missing dependency - invoices.'); } - if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && ! array_key_exists('expenses', $this->ids)) { + if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && !array_key_exists('expenses', $this->ids)) { return; //throw new ResourceDependencyMissing('Processing documents failed, because of missing dependency - expenses.'); } @@ -1389,7 +1389,7 @@ class Import implements ShouldQueue } } - if (! $entity) { + if (!$entity) { continue; } // throw new Exception("Resource invoice/quote document not available."); @@ -1402,7 +1402,7 @@ class Import implements ShouldQueue $file_url = $resource['url']; $file_name = $resource['name']; - $file_path = sys_get_temp_dir().'/'.$file_name; + $file_path = sys_get_temp_dir() . '/' . $file_name; try { file_put_contents($file_path, $this->curlGet($file_url)); @@ -1410,13 +1410,13 @@ class Import implements ShouldQueue $file_info = $finfo->file($file_path); $uploaded_file = new UploadedFile( - $file_path, - $file_name, - $file_info, - filesize($file_path), - 0, - false - ); + $file_path, + $file_name, + $file_info, + filesize($file_path), + 0, + false + ); $this->saveDocument($uploaded_file, $entity, $is_public = true); } catch (\Exception $e) { @@ -1426,7 +1426,7 @@ class Import implements ShouldQueue } } - private function processPaymentTerms(array $data) :void + private function processPaymentTerms(array $data): void { PaymentTerm::unguard(); @@ -1446,7 +1446,7 @@ class Import implements ShouldQueue $data = null; } - private function processCompanyGateways(array $data) :void + private function processCompanyGateways(array $data): void { CompanyGateway::unguard(); @@ -1477,7 +1477,7 @@ class Import implements ShouldQueue $modified['fees_and_limits'] = $this->cleanFeesAndLimits($modified['fees_and_limits']); } - if (! array_key_exists('accepted_credit_cards', $modified) || (array_key_exists('accepted_credit_cards', $modified) && empty($modified['accepted_credit_cards']))) { + if (!array_key_exists('accepted_credit_cards', $modified) || (array_key_exists('accepted_credit_cards', $modified) && empty($modified['accepted_credit_cards']))) { $modified['accepted_credit_cards'] = 0; } @@ -1513,7 +1513,7 @@ class Import implements ShouldQueue $data = null; } - private function processClientGatewayTokens(array $data) :void + private function processClientGatewayTokens(array $data): void { ClientGatewayToken::unguard(); @@ -1544,7 +1544,7 @@ class Import implements ShouldQueue $data = null; } - private function processTaskStatuses(array $data) :void + private function processTaskStatuses(array $data): void { info('in task statuses'); TaskStatus::unguard(); @@ -1573,7 +1573,7 @@ class Import implements ShouldQueue info('finished task statuses'); } - private function processExpenseCategories(array $data) :void + private function processExpenseCategories(array $data): void { ExpenseCategory::unguard(); @@ -1602,7 +1602,7 @@ class Import implements ShouldQueue $data = null; } - private function processTasks(array $data) :void + private function processTasks(array $data): void { Task::unguard(); @@ -1657,7 +1657,7 @@ class Import implements ShouldQueue $data = null; } - private function processProjects(array $data) :void + private function processProjects(array $data): void { Project::unguard(); @@ -1688,7 +1688,7 @@ class Import implements ShouldQueue $data = null; } - private function processExpenses(array $data) :void + private function processExpenses(array $data): void { Expense::unguard(); @@ -1765,7 +1765,7 @@ class Import implements ShouldQueue { $user = MultiDB::hasUser(['email' => $data]); - if (! $user) { + if (!$user) { $user = UserFactory::create($this->company->account->id); } @@ -1780,12 +1780,12 @@ class Import implements ShouldQueue */ public function transformId($resource, string $old): int { - if (! array_key_exists($resource, $this->ids)) { + if (!array_key_exists($resource, $this->ids)) { info(print_r($resource, 1)); throw new Exception("Resource {$resource} not available."); } - if (! array_key_exists("{$resource}_{$old}", $this->ids[$resource])) { + if (!array_key_exists("{$resource}_{$old}", $this->ids[$resource])) { throw new Exception("Missing resource key: {$resource}_{$old}"); } @@ -1794,11 +1794,11 @@ class Import implements ShouldQueue private function tryTransformingId($resource, string $old): ?int { - if (! array_key_exists($resource, $this->ids)) { + if (!array_key_exists($resource, $this->ids)) { return false; } - if (! array_key_exists("{$resource}_{$old}", $this->ids[$resource])) { + if (!array_key_exists("{$resource}_{$old}", $this->ids[$resource])) { return false; } @@ -1814,11 +1814,11 @@ class Import implements ShouldQueue */ public function processUserId(array $resource) { - if (! array_key_exists('user_id', $resource)) { + if (!array_key_exists('user_id', $resource)) { return $this->user->id; } - if (array_key_exists('user_id', $resource) && ! array_key_exists('users', $this->ids)) { + if (array_key_exists('user_id', $resource) && !array_key_exists('users', $this->ids)) { return $this->user->id; } @@ -1834,7 +1834,7 @@ class Import implements ShouldQueue $job_failure->string_metric6 = $exception->getMessage(); LightLogs::create($job_failure) - ->queue(); + ->queue(); info(print_r($exception->getMessage(), 1)); @@ -1866,7 +1866,8 @@ class Import implements ShouldQueue if (Ninja::isHosted()) { try { - \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow($data, $this->company); + \Modules\Admin\Jobs\Account\NinjaUser::dispatchSync($data, $this->company); + } catch (\Exception $e) { nlog($e->getMessage()); } diff --git a/app/Jobs/Util/StartMigration.php b/app/Jobs/Util/StartMigration.php index 40c532e6b95f..27ad98cdaaa8 100644 --- a/app/Jobs/Util/StartMigration.php +++ b/app/Jobs/Util/StartMigration.php @@ -116,7 +116,7 @@ class StartMigration implements ShouldQueue throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.'); } - Import::dispatchNow($file, $this->company, $this->user); + Import::dispatchSync($file, $this->company, $this->user); Storage::deleteDirectory(public_path("storage/migrations/{$filename}")); diff --git a/app/Listeners/Quote/ReachWorkflowSettings.php b/app/Listeners/Quote/ReachWorkflowSettings.php index 1ca8dbe06fcc..8d4733fdb83f 100644 --- a/app/Listeners/Quote/ReachWorkflowSettings.php +++ b/app/Listeners/Quote/ReachWorkflowSettings.php @@ -27,6 +27,6 @@ class ReachWorkflowSettings { MultiDB::setDb($event->company->db); - QuoteWorkflowSettings::dispatchNow($event->quote); + QuoteWorkflowSettings::dispatchSync($event->quote); } } diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 63727a173721..1a4de0d489c9 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -133,7 +133,7 @@ class TemplateEmail extends Mailable } if ($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { - $ubl_string = CreateUbl::dispatchNow($this->invitation->invoice); + $ubl_string = (new CreateUbl($this->invitation->invoice))->handle(); if ($ubl_string) { $this->attachData($ubl_string, $this->invitation->invoice->getFileName('xml')); diff --git a/app/Models/Credit.php b/app/Models/Credit.php index b818a9875f46..f1aac09e2aff 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -283,7 +283,7 @@ class Credit extends BaseModel if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) { return Storage::disk(config('filesystems.default'))->{$type}($file_path); } elseif (Ninja::isHosted() && $portal) { - $file_path = CreateEntityPdf::dispatchNow($invitation, config('filesystems.default')); + $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle(); return Storage::disk(config('filesystems.default'))->{$type}($file_path); } @@ -292,7 +292,8 @@ class Credit extends BaseModel return Storage::disk('public')->{$type}($file_path); } - $file_path = CreateEntityPdf::dispatchNow($invitation); + + $file_path = (new CreateEntityPdf($invitation))->handle(); return Storage::disk('public')->{$type}($file_path); } diff --git a/app/Models/CreditInvitation.php b/app/Models/CreditInvitation.php index b21554f8e3fa..ba32dd04f9aa 100644 --- a/app/Models/CreditInvitation.php +++ b/app/Models/CreditInvitation.php @@ -130,7 +130,7 @@ class CreditInvitation extends BaseModel if (! Storage::exists($this->credit->client->credit_filepath($this).$this->credit->numberFormatter().'.pdf')) { event(new CreditWasUpdated($this, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); - CreateEntityPdf::dispatchNow($this); + CreateEntityPdf::dispatchSync($this); } return $storage_path; diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 6f5a1d6f94c0..886f3bf3b831 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -443,7 +443,7 @@ class Invoice extends BaseModel if (Ninja::isHosted() && $portal && $file_exists) { return Storage::disk(config('filesystems.default'))->{$type}($file_path); } elseif (Ninja::isHosted()) { - $file_path = CreateEntityPdf::dispatchNow($invitation, config('filesystems.default')); + $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle(); return Storage::disk(config('filesystems.default'))->{$type}($file_path); } @@ -458,7 +458,7 @@ class Invoice extends BaseModel return Storage::disk('public')->{$type}($file_path); } - $file_path = CreateEntityPdf::dispatchNow($invitation); + $file_path = (new CreateEntityPdf($invitation))->handle(); return Storage::disk('public')->{$type}($file_path); } diff --git a/app/Models/InvoiceInvitation.php b/app/Models/InvoiceInvitation.php index 062e02a47a56..34da795f342b 100644 --- a/app/Models/InvoiceInvitation.php +++ b/app/Models/InvoiceInvitation.php @@ -112,7 +112,7 @@ class InvoiceInvitation extends BaseModel if (! Storage::exists($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf')) { event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); - CreateEntityPdf::dispatchNow($this); + CreateEntityPdf::dispatchSync($this); } return $storage_path; diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index 648688916f26..1c3891f42649 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -212,7 +212,7 @@ class PurchaseOrder extends BaseModel if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) { return Storage::disk(config('filesystems.default'))->{$type}($file_path); } elseif (Ninja::isHosted() && $portal) { - $file_path = CreatePurchaseOrderPdf::dispatchNow($invitation, config('filesystems.default')); + $file_path = (new CreatePurchaseOrderPdf($invitation, config('filesystems.default')))->handle(); return Storage::disk(config('filesystems.default'))->{$type}($file_path); } @@ -221,8 +221,7 @@ class PurchaseOrder extends BaseModel return Storage::disk('public')->{$type}($file_path); } - $file_path = CreatePurchaseOrderPdf::dispatchNow($invitation); - + $file_path = (new CreatePurchaseOrderPdf($invitation))->handle(); return Storage::disk('public')->{$type}($file_path); } diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 0f3f900fa015..c512c288aa19 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -242,8 +242,8 @@ class Quote extends BaseModel if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) { return Storage::disk(config('filesystems.default'))->{$type}($file_path); } elseif (Ninja::isHosted() && $portal) { - $file_path = CreateEntityPdf::dispatchNow($invitation, config('filesystems.default')); + $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle(); return Storage::disk(config('filesystems.default'))->{$type}($file_path); } @@ -251,7 +251,7 @@ class Quote extends BaseModel return Storage::disk('public')->{$type}($file_path); } - $file_path = CreateEntityPdf::dispatchNow($invitation); + $file_path = (new CreateEntityPdf($invitation))->handle(); return Storage::disk('public')->{$type}($file_path); } diff --git a/app/Models/QuoteInvitation.php b/app/Models/QuoteInvitation.php index adb0b7090c73..bb6fce43867a 100644 --- a/app/Models/QuoteInvitation.php +++ b/app/Models/QuoteInvitation.php @@ -134,7 +134,7 @@ class QuoteInvitation extends BaseModel if (! Storage::exists($this->quote->client->quote_filepath($this).$this->quote->numberFormatter().'.pdf')) { event(new QuoteWasUpdated($this->quote, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); - CreateEntityPdf::dispatchNow($this); + CreateEntityPdf::dispatchSync($this); } return $storage_path; diff --git a/app/Notifications/BaseNotification.php b/app/Notifications/BaseNotification.php index ee3ad743f571..20a73b431b72 100644 --- a/app/Notifications/BaseNotification.php +++ b/app/Notifications/BaseNotification.php @@ -94,7 +94,7 @@ class BaseNotification extends Notification } if ($this->entity instanceof Invoice && $this->settings->ubl_email_attachment) { - $ubl_string = CreateUbl::dispatchNow($this->entity); + $ubl_string = (new Createubl($this->entity))->handle(); $mail_message->attachData($ubl_string, $this->entity->getFileName('xml')); } diff --git a/app/Repositories/PaymentRepository.php b/app/Repositories/PaymentRepository.php index 12bb35f66b7e..ff696a05d722 100644 --- a/app/Repositories/PaymentRepository.php +++ b/app/Repositories/PaymentRepository.php @@ -164,7 +164,7 @@ class PaymentRepository extends BaseRepository if ($credit) { $credit = $credit->service()->markSent()->save(); - ApplyCreditPayment::dispatchNow($credit, $payment, $paid_credit['amount'], $credit->company); + ApplyCreditPayment::dispatchSync($credit, $payment, $paid_credit['amount'], $credit->company); } } } diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index dccdbcca6e86..ec43ceed2403 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -196,7 +196,7 @@ class CreditService try { if ($force) { $this->credit->invitations->each(function ($invitation) { - CreateEntityPdf::dispatchNow($invitation); + CreateEntityPdf::dispatchSync($invitation); }); return $this; @@ -243,7 +243,7 @@ class CreditService public function deletePdf() { $this->credit->invitations->each(function ($invitation) { - UnlinkFile::dispatchNow(config('filesystems.default'), $this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf'); + UnlinkFile::dispatchSync(config('filesystems.default'), $this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf'); }); return $this; diff --git a/app/Services/Credit/GetCreditPdf.php b/app/Services/Credit/GetCreditPdf.php index dbbc539812f5..1b6ce982ebd0 100644 --- a/app/Services/Credit/GetCreditPdf.php +++ b/app/Services/Credit/GetCreditPdf.php @@ -44,8 +44,7 @@ class GetCreditPdf extends AbstractService // $disk = 'public'; $disk = config('filesystems.default'); - $file_path = CreateEntityPdf::dispatchNow($this->invitation); - + $file_path = (new CreateEntityPdf($this->invitation))->handle(); return $file_path; } } diff --git a/app/Services/Credit/SendEmail.php b/app/Services/Credit/SendEmail.php index 1bca99407004..e7e6c48fe558 100644 --- a/app/Services/Credit/SendEmail.php +++ b/app/Services/Credit/SendEmail.php @@ -48,7 +48,7 @@ class SendEmail // $email_builder = (new CreditEmail())->build($invitation, $this->reminder_template); // EmailCredit::dispatchNow($email_builder, $invitation, $invitation->company); - EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template); + EmailEntity::dispatchSync($invitation, $invitation->company, $this->reminder_template); } }); diff --git a/app/Services/Invoice/GetInvoicePdf.php b/app/Services/Invoice/GetInvoicePdf.php index 571d4f22e134..16ff30c38bb8 100644 --- a/app/Services/Invoice/GetInvoicePdf.php +++ b/app/Services/Invoice/GetInvoicePdf.php @@ -49,7 +49,7 @@ class GetInvoicePdf extends AbstractService $file = Storage::disk($disk)->exists($file_path); if (! $file) { - $file_path = CreateEntityPdf::dispatchNow($invitation); + $file_path = (new CreateEntityPdf($invitation))->handle(); } return $file_path; diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 55ec086f7576..3ce240e14c41 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -418,7 +418,7 @@ class InvoiceService try { if ($force) { $this->invoice->invitations->each(function ($invitation) { - CreateEntityPdf::dispatchNow($invitation); + CreateEntityPdf::dispatchSync($invitation); }); return $this; @@ -557,7 +557,7 @@ class InvoiceService public function adjustInventory($old_invoice = []) { if ($this->invoice->company->track_inventory) { - AdjustProductInventory::dispatchNow($this->invoice->company, $this->invoice, $old_invoice); + AdjustProductInventory::dispatchSync($this->invoice->company, $this->invoice, $old_invoice); } return $this; diff --git a/app/Services/Invoice/SendEmail.php b/app/Services/Invoice/SendEmail.php index 20b6f6b74b41..10a35479c460 100644 --- a/app/Services/Invoice/SendEmail.php +++ b/app/Services/Invoice/SendEmail.php @@ -45,7 +45,7 @@ class SendEmail extends AbstractService $this->invoice->invitations->each(function ($invitation) { if (! $invitation->contact->trashed() && $invitation->contact->email) { - EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template); + EmailEntity::dispatchSync($invitation, $invitation->company, $this->reminder_template); } }); } diff --git a/app/Services/Payment/SendEmail.php b/app/Services/Payment/SendEmail.php index 100c4ee4b0d8..87ff586edcdf 100644 --- a/app/Services/Payment/SendEmail.php +++ b/app/Services/Payment/SendEmail.php @@ -36,9 +36,9 @@ class SendEmail $this->payment->client->contacts->each(function ($contact) { if ($contact->email) { - EmailPayment::dispatchNow($this->payment, $this->payment->company, $contact); - - return false; + // dispatchSync always returns 0, in this case we can handle it without returning false; + return EmailPayment::dispatchSync($this->payment, $this->payment->company, $contact); + // return false; //11-01-2021 only send payment receipt to the first contact } }); diff --git a/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php b/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php index f4969d97081c..5d00388b8371 100644 --- a/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php +++ b/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php @@ -49,7 +49,7 @@ class GetPurchaseOrderPdf extends AbstractService $file = Storage::disk($disk)->exists($file_path); if (! $file) { - $file_path = CreatePurchaseOrderPdf::dispatchNow($invitation); + $file_path = (new CreatePurchaseOrderPdf($invitation))->handle(); } return $file_path; diff --git a/app/Services/PurchaseOrder/PurchaseOrderService.php b/app/Services/PurchaseOrder/PurchaseOrderService.php index 19ed6b7489db..c88494361bef 100644 --- a/app/Services/PurchaseOrder/PurchaseOrderService.php +++ b/app/Services/PurchaseOrder/PurchaseOrderService.php @@ -91,7 +91,7 @@ class PurchaseOrderService try { if ($force) { $this->purchase_order->invitations->each(function ($invitation) { - CreatePurchaseOrderPdf::dispatchNow($invitation); + CreatePurchaseOrderPdf::dispatchSync($invitation); }); return $this; diff --git a/app/Services/Quote/GetQuotePdf.php b/app/Services/Quote/GetQuotePdf.php index 7448b9e7ccd2..2c6d6e820ed3 100644 --- a/app/Services/Quote/GetQuotePdf.php +++ b/app/Services/Quote/GetQuotePdf.php @@ -29,7 +29,7 @@ class GetQuotePdf extends AbstractService public function run() { - if (! $this->contact) { + if (!$this->contact) { $this->contact = $this->quote->client->primary_contact()->first() ?: $this->quote->client->contacts()->first(); } @@ -37,12 +37,13 @@ class GetQuotePdf extends AbstractService $path = $this->quote->client->quote_filepath($invitation); - $file_path = $path.$this->quote->numberFormatter().'.pdf'; + $file_path = $path . $this->quote->numberFormatter() . '.pdf'; // $disk = 'public'; $disk = config('filesystems.default'); - $file_path = CreateEntityPdf::dispatchNow($invitation); + + $file_path = (new CreateEntityPdf($invitation))->handle(); return $file_path; //return Storage::disk($disk)->path($file_path); diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index 29f9abd0865b..62414cec3377 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -136,7 +136,7 @@ class QuoteService try { if ($force) { $this->quote->invitations->each(function ($invitation) { - CreateEntityPdf::dispatchNow($invitation); + CreateEntityPdf::dispatchSync($invitation); }); return $this; @@ -225,7 +225,7 @@ class QuoteService public function deletePdf() { $this->quote->invitations->each(function ($invitation) { - UnlinkFile::dispatchNow(config('filesystems.default'), $this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf'); + UnlinkFile::dispatchSync(config('filesystems.default'), $this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf'); }); return $this; diff --git a/app/Services/Quote/SendEmail.php b/app/Services/Quote/SendEmail.php index db6663e1ace7..acaf4b2ce2a8 100644 --- a/app/Services/Quote/SendEmail.php +++ b/app/Services/Quote/SendEmail.php @@ -43,7 +43,7 @@ class SendEmail $this->quote->invitations->each(function ($invitation) { if (! $invitation->contact->trashed() && $invitation->contact->email) { - EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template); + EmailEntity::dispatchSync($invitation, $invitation->company, $this->reminder_template); } }); diff --git a/app/Services/Recurring/GetInvoicePdf.php b/app/Services/Recurring/GetInvoicePdf.php index 43db4fd5adc6..bde2f4b6ff65 100644 --- a/app/Services/Recurring/GetInvoicePdf.php +++ b/app/Services/Recurring/GetInvoicePdf.php @@ -46,7 +46,7 @@ class GetInvoicePdf extends AbstractService $file = Storage::disk($disk)->exists($file_path); if (! $file) { - $file_path = CreateEntityPdf::dispatchNow($invitation); + $file_path = (new CreateEntityPdf($invitation))->handle(); } return $file_path; diff --git a/app/Services/Recurring/RecurringService.php b/app/Services/Recurring/RecurringService.php index e97939d6a4c6..83ae7b23e129 100644 --- a/app/Services/Recurring/RecurringService.php +++ b/app/Services/Recurring/RecurringService.php @@ -85,7 +85,7 @@ class RecurringService public function deletePdf() { $this->recurring_entity->invitations->each(function ($invitation) { - UnlinkFile::dispatchNow(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation).$this->recurring_entity->numberFormatter().'.pdf'); + UnlinkFile::dispatchSync(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation).$this->recurring_entity->numberFormatter().'.pdf'); }); return $this; diff --git a/app/Utils/Traits/SavesDocuments.php b/app/Utils/Traits/SavesDocuments.php index 14546d335650..47b2e006870f 100644 --- a/app/Utils/Traits/SavesDocuments.php +++ b/app/Utils/Traits/SavesDocuments.php @@ -34,7 +34,7 @@ trait SavesDocuments } foreach ($document_array as $document) { - $document = UploadFile::dispatchNow( + $document = (new UploadFile( $document, UploadFile::DOCUMENT, $user, @@ -42,7 +42,7 @@ trait SavesDocuments $entity, null, $is_public - ); + ))->handle(); } } @@ -62,7 +62,7 @@ trait SavesDocuments return false; } - $document = UploadFile::dispatchNow( + $document = (new UploadFile( $document, UploadFile::DOCUMENT, $user, @@ -70,6 +70,6 @@ trait SavesDocuments $entity, null, $is_public - ); + ))->handle(); } } diff --git a/app/Utils/Traits/Uploadable.php b/app/Utils/Traits/Uploadable.php index 0ebd9e1b67a7..3284c5ce3069 100644 --- a/app/Utils/Traits/Uploadable.php +++ b/app/Utils/Traits/Uploadable.php @@ -23,15 +23,14 @@ trait Uploadable public function removeLogo($company) { if (Storage::exists($company->settings->company_logo)) { - UnlinkFile::dispatchNow(config('filesystems.default'), $company->settings->company_logo); + UnlinkFile::dispatchSync(config('filesystems.default'), $company->settings->company_logo); } } public function uploadLogo($file, $company, $entity) { if ($file) { - $path = UploadAvatar::dispatchNow($file, $company->company_key); - + $path = (new UploadAvatar($file, $company->company_key))->handle(); if ($path) { $settings = $entity->settings; $settings->company_logo = $path; diff --git a/tests/Feature/Export/ExportCompanyTest.php b/tests/Feature/Export/ExportCompanyTest.php index 6aff3a58b906..307d45f917b8 100644 --- a/tests/Feature/Export/ExportCompanyTest.php +++ b/tests/Feature/Export/ExportCompanyTest.php @@ -28,7 +28,7 @@ class ExportCompanyTest extends TestCase use MakesHash; use MockAccountData; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -42,14 +42,14 @@ class ExportCompanyTest extends TestCase $this->withoutExceptionHandling(); - if (! config('ninja.testvars.stripe')) { + if (!config('ninja.testvars.stripe')) { $this->markTestSkipped('Cannot write to TMP - skipping'); } } public function testCompanyExport() { - $res = CompanyExport::dispatchNow($this->company, $this->company->users->first()); + $res = (new CompanyExport($this->company, $this->company->users->first()))->handle(); $this->assertTrue($res); } diff --git a/tests/Feature/Import/ImportCsvTest.php b/tests/Feature/Import/ImportCsvTest.php index 026e645d7e3c..d234c15dd829 100644 --- a/tests/Feature/Import/ImportCsvTest.php +++ b/tests/Feature/Import/ImportCsvTest.php @@ -87,7 +87,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-client', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); $this->assertGreaterThan($pre_import, Client::count()); } @@ -117,7 +117,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-client', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); /*Now import invoices*/ $csv = file_get_contents(base_path().'/tests/Feature/Import/invoice.csv'); @@ -152,7 +152,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-invoice', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); $this->assertGreaterThan($pre_import, Invoice::count()); } @@ -181,7 +181,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-vendor', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); $this->assertGreaterThan($pre_import, Vendor::count()); } @@ -207,7 +207,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-product', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); $this->assertGreaterThan($pre_import, Product::count()); } @@ -233,7 +233,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-expense', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); $this->assertGreaterThan($pre_import, Expense::count()); } @@ -264,7 +264,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-client', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); /*Now import invoices*/ $csv = file_get_contents(base_path().'/tests/Feature/Import/invoice.csv'); @@ -299,7 +299,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-invoice', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); /* Test Now import payments*/ @@ -324,7 +324,7 @@ class ImportCsvTest extends TestCase Cache::put($hash.'-payment', base64_encode($csv), 360); - CSVImport::dispatchNow($data, $this->company); + CSVImport::dispatchSync($data, $this->company); $this->assertGreaterThan($pre_import, Payment::count()); } diff --git a/tests/Feature/InvoiceEmailTest.php b/tests/Feature/InvoiceEmailTest.php index b7b9bc25abed..9d16fa7ab17c 100644 --- a/tests/Feature/InvoiceEmailTest.php +++ b/tests/Feature/InvoiceEmailTest.php @@ -61,7 +61,7 @@ class InvoiceEmailTest extends TestCase $this->invoice->invitations->each(function ($invitation) { if ($invitation->contact->send_email && $invitation->contact->email) { - EmailEntity::dispatchNow($invitation, $invitation->company); + EmailEntity::dispatchSync($invitation, $invitation->company); $this->expectsJobs(EmailEntity::class); } @@ -89,7 +89,7 @@ class InvoiceEmailTest extends TestCase $this->invoice->invitations->each(function ($invitation) { if ($invitation->contact->send_email && $invitation->contact->email) { - EmailEntity::dispatchNow($invitation, $invitation->company); + EmailEntity::dispatchSync($invitation, $invitation->company); $this->expectsJobs(EmailEntity::class); } @@ -117,7 +117,7 @@ class InvoiceEmailTest extends TestCase $this->invoice->invitations->each(function ($invitation) { if ($invitation->contact->send_email && $invitation->contact->email) { - EmailEntity::dispatchNow($invitation, $invitation->company); + EmailEntity::dispatchSync($invitation, $invitation->company); $this->expectsJobs(EmailEntity::class); } @@ -140,7 +140,7 @@ class InvoiceEmailTest extends TestCase $this->invoice->invitations->each(function ($invitation) { if ($invitation->contact->send_email && $invitation->contact->email) { - EmailEntity::dispatchNow($invitation, $invitation->company); + EmailEntity::dispatchSync($invitation, $invitation->company); $this->expectsJobs(EmailEntity::class); } diff --git a/tests/Feature/PdfCreatorTest.php b/tests/Feature/PdfCreatorTest.php index 01b85d62dbc7..6d42a20e35b0 100644 --- a/tests/Feature/PdfCreatorTest.php +++ b/tests/Feature/PdfCreatorTest.php @@ -39,21 +39,21 @@ class PdfCreatorTest extends TestCase public function testCreditPdfCreated() { - $credit_path = CreateEntityPdf::dispatchNow($this->credit->invitations->first()); + $credit_path = (new CreateEntityPdf($this->credit->invitations->first()))->handle(); $this->assertTrue(Storage::disk('public')->exists($credit_path)); } public function testInvoicePdfCreated() { - $invoice_path = CreateEntityPdf::dispatchNow($this->invoice->invitations->first()); + $invoice_path = (new CreateEntityPdf($this->invoice->invitations->first()))->handle(); $this->assertTrue(Storage::disk('public')->exists($invoice_path)); } public function testQuotePdfCreated() { - $quote_path = CreateEntityPdf::dispatchNow($this->quote->invitations->first()); + $quote_path = (new CreateEntityPdf($this->quote->invitations->first()))->handle(); $this->assertTrue(Storage::disk('public')->exists($quote_path)); } diff --git a/tests/Feature/UpdateExchangeRatesTest.php b/tests/Feature/UpdateExchangeRatesTest.php index 82b219dd7d94..3420f559ddfa 100644 --- a/tests/Feature/UpdateExchangeRatesTest.php +++ b/tests/Feature/UpdateExchangeRatesTest.php @@ -55,7 +55,7 @@ class UpdateExchangeRatesTest extends TestCase $currency_api = json_decode($response->getBody()); - UpdateExchangeRates::dispatchNow(); + UpdateExchangeRates::dispatchSync(); $currencies = Cache::get('currencies'); diff --git a/tests/Integration/InvoiceUploadTest.php b/tests/Integration/InvoiceUploadTest.php index 8b851b795f4c..e0222290d355 100644 --- a/tests/Integration/InvoiceUploadTest.php +++ b/tests/Integration/InvoiceUploadTest.php @@ -34,7 +34,7 @@ class InvoiceUploadTest extends TestCase public function testInvoiceUploadWorks() { - CreateEntityPdf::dispatchNow($this->invoice->invitations->first()); + CreateEntityPdf::dispatchSync($this->invoice->invitations->first()); $this->assertNotNull($this->invoice->service()->getInvoicePdf($this->invoice->client->primary_contact()->first())); } diff --git a/tests/Integration/PostmarkWebhookTest.php b/tests/Integration/PostmarkWebhookTest.php index e43fa27920a0..c56996c4e8b0 100644 --- a/tests/Integration/PostmarkWebhookTest.php +++ b/tests/Integration/PostmarkWebhookTest.php @@ -70,7 +70,7 @@ class PostmarkWebhookTest extends TestCase $invitation->message_id = '00000000-0000-0000-0000-000000000000'; $invitation->save(); - ProcessPostmarkWebhook::dispatchNow([ + ProcessPostmarkWebhook::dispatchSync([ 'RecordType' => 'Delivery', 'ServerID' => '23', 'MessageStream' => 'outbound', @@ -118,7 +118,7 @@ class PostmarkWebhookTest extends TestCase $invitation->message_id = '00000000-0000-0000-0000-000000000001'; $invitation->save(); - ProcessPostmarkWebhook::dispatchNow([ + ProcessPostmarkWebhook::dispatchSync([ 'RecordType' => 'SpamComplaint', 'ServerID' => '23', 'MessageStream' => 'outbound', diff --git a/tests/Integration/UploadFileTest.php b/tests/Integration/UploadFileTest.php index 6b730712d0d0..7af89ba79e58 100644 --- a/tests/Integration/UploadFileTest.php +++ b/tests/Integration/UploadFileTest.php @@ -42,13 +42,13 @@ class UploadFileTest extends TestCase { $image = UploadedFile::fake()->image('avatar.jpg'); - $document = UploadFile::dispatchNow( + $document = (new UploadFile( $image, UploadFile::IMAGE, $this->invoice->user, $this->invoice->company, $this->invoice - ); + ))->handle(); $this->assertNotNull($document); } diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index c05ac7dc64dd..db38a80a05a4 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -236,7 +236,7 @@ trait MockAccountData // auth()->login($user); - CreateCompanyTaskStatuses::dispatchNow($this->company, $this->user); + CreateCompanyTaskStatuses::dispatchSync($this->company, $this->user); $this->cu = CompanyUserFactory::create($user->id, $this->company->id, $this->account->id); $this->cu->is_owner = true; diff --git a/tests/Unit/CompanyDocumentsTest.php b/tests/Unit/CompanyDocumentsTest.php index 1b9634a54adf..f03bc34a6252 100644 --- a/tests/Unit/CompanyDocumentsTest.php +++ b/tests/Unit/CompanyDocumentsTest.php @@ -25,7 +25,7 @@ class CompanyDocumentsTest extends TestCase use MockAccountData; use DatabaseTransactions; - protected function setUp() :void + protected function setUp(): void { parent::setUp(); @@ -44,13 +44,13 @@ class CompanyDocumentsTest extends TestCase $image = UploadedFile::fake()->image('avatar.jpg'); - $document = UploadFile::dispatchNow( + + $document = (new UploadFile( $image, UploadFile::IMAGE, $this->user, $this->company, - $this->invoice - ); + $this->invoice))->handle(); $this->assertNotNull($document); diff --git a/tests/Unit/UBLInvoiceTest.php b/tests/Unit/UBLInvoiceTest.php index 2c50cccd6dc0..99e363ba960b 100644 --- a/tests/Unit/UBLInvoiceTest.php +++ b/tests/Unit/UBLInvoiceTest.php @@ -38,8 +38,7 @@ class UBLInvoiceTest extends TestCase public function testUblGenerates() { - $ubl = CreateUbl::dispatchNow($this->invoice); - + $ubl = (new CreateUbl($this->invoice))->handle(); $this->assertNotNull($ubl); } }