Updates for Static Analysis

This commit is contained in:
David Bomba 2023-08-04 16:40:44 +10:00
parent a0fab8d22d
commit b09f1a7d07
30 changed files with 201 additions and 167 deletions

View File

@ -120,6 +120,7 @@ class PaymentFilters extends QueryFilters
*/ */
public function match_transactions($value = 'true'): Builder public function match_transactions($value = 'true'): Builder
{ {
if ($value == 'true') { if ($value == 'true') {
return $this->builder return $this->builder
->where('is_deleted', 0) ->where('is_deleted', 0)

View File

@ -101,7 +101,11 @@ class ContactForgotPasswordController extends Controller
$this->validateEmail($request); $this->validateEmail($request);
if (Ninja::isHosted() && $company = Company::where('company_key', $request->input('company_key'))->first()) { if (Ninja::isHosted() && $company = Company::where('company_key', $request->input('company_key'))->first()) {
/** @var \App\Models\Company $company **/
/** @var \App\Models\ClientContact $contact **/
$contact = ClientContact::where(['email' => $request->input('email'), 'company_id' => $company->id]) $contact = ClientContact::where(['email' => $request->input('email'), 'company_id' => $company->id])
->whereHas('client', function ($query) { ->whereHas('client', function ($query) {
$query->where('is_deleted', 0); $query->where('is_deleted', 0);

View File

@ -52,6 +52,7 @@ class ContactLoginController extends Controller
$company = Company::where('company_key', $company_key)->first(); $company = Company::where('company_key', $company_key)->first();
} }
/** @var \App\Models\Company $company **/
if ($company) { if ($company) {
$account = $company->account; $account = $company->account;
} elseif (! $company && strpos($request->getHost(), 'invoicing.co') !== false) { } elseif (! $company && strpos($request->getHost(), 'invoicing.co') !== false) {
@ -63,6 +64,7 @@ class ContactLoginController extends Controller
$company = Company::where('portal_domain', $request->getSchemeAndHttpHost())->first(); $company = Company::where('portal_domain', $request->getSchemeAndHttpHost())->first();
} elseif (Ninja::isSelfHost()) { } elseif (Ninja::isSelfHost()) {
/** @var \App\Models\Account $account **/
$account = Account::first(); $account = Account::first();
$company = $account->default_company; $company = $account->default_company;
} else { } else {
@ -97,6 +99,7 @@ class ContactLoginController extends Controller
} }
if (Ninja::isHosted() && $request->has('password') && $company = Company::where('company_key', $request->input('company_key'))->first()) { if (Ninja::isHosted() && $request->has('password') && $company = Company::where('company_key', $request->input('company_key'))->first()) {
/** @var \App\Models\Company $company **/
$contact = ClientContact::where(['email' => $request->input('email'), 'company_id' => $company->id]) $contact = ClientContact::where(['email' => $request->input('email'), 'company_id' => $company->id])
->whereHas('client', function ($query) { ->whereHas('client', function ($query) {
$query->where('is_deleted', 0); $query->where('is_deleted', 0);

View File

@ -40,6 +40,7 @@ class ContactRegisterController extends Controller
$key = request()->session()->has('company_key') ? request()->session()->get('company_key') : $company_key; $key = request()->session()->has('company_key') ? request()->session()->get('company_key') : $company_key;
} }
/** @var \App\Models\Company $company **/
$company = Company::where('company_key', $key)->firstOrFail(); $company = Company::where('company_key', $key)->firstOrFail();
App::forgetInstance('translator'); App::forgetInstance('translator');

View File

@ -71,6 +71,8 @@ class ContactResetPasswordController extends Controller
{ {
if ($request->session()->has('company_key')) { if ($request->session()->has('company_key')) {
MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key')); MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key'));
/** @var \App\Models\Company $company **/
$company = Company::where('company_key', $request->session()->get('company_key'))->first(); $company = Company::where('company_key', $request->session()->get('company_key'))->first();
$db = $company->db; $db = $company->db;
$account = $company->account; $account = $company->account;
@ -79,10 +81,12 @@ class ContactResetPasswordController extends Controller
if ($account_key) { if ($account_key) {
MultiDB::findAndSetDbByAccountKey($account_key); MultiDB::findAndSetDbByAccountKey($account_key);
/** @var \App\Models\Account $account **/
$account = Account::where('key', $account_key)->first(); $account = Account::where('key', $account_key)->first();
$db = $account->companies->first()->db; $db = $account->companies->first()->db;
$company = $account->companies->first(); $company = $account->companies->first();
} else { } else {
/** @var \App\Models\Account $account **/
$account = Account::first(); $account = Account::first();
$db = $account->companies->first()->db; $db = $account->companies->first()->db;
$company = $account->companies->first(); $company = $account->companies->first();

View File

@ -82,6 +82,7 @@ class ForgotPasswordController extends Controller
{ {
if ($request->has('company_key')) { if ($request->has('company_key')) {
MultiDB::findAndSetDbByCompanyKey($request->input('company_key')); MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
/** @var \App\Models\Company $company **/
$company = Company::where('company_key', $request->input('company_key'))->first(); $company = Company::where('company_key', $request->input('company_key'))->first();
$account = $company->account; $account = $company->account;
} else { } else {

View File

@ -60,6 +60,7 @@ class ResetPasswordController extends Controller
if (Ninja::isHosted()) { if (Ninja::isHosted()) {
MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key')); MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key'));
/** @var \App\Models\Company $company **/
$company = Company::where('company_key', $request->session()->get('company_key'))->first(); $company = Company::where('company_key', $request->session()->get('company_key'))->first();
} }

View File

@ -85,7 +85,7 @@ class BankTransactionRuleController extends BaseController
* @OA\JsonContent(ref="#/components/schemas/Error"), * @OA\JsonContent(ref="#/components/schemas/Error"),
* ), * ),
* ) * )
* @param BankTransactionFilters $filter * @param BankTransactionRuleFilters $filters
* @return Response|mixed * @return Response|mixed
*/ */
public function index(BankTransactionRuleFilters $filters) public function index(BankTransactionRuleFilters $filters)
@ -302,7 +302,9 @@ class BankTransactionRuleController extends BaseController
*/ */
public function create(CreateBankTransactionRuleRequest $request) public function create(CreateBankTransactionRuleRequest $request)
{ {
$bank_transaction_rule = BankTransactionRuleFactory::create(auth()->user()->company()->id, auth()->user()->id, auth()->user()->account_id); /** @var \App\Models\User $user **/
$user = auth()->user();
$bank_transaction_rule = BankTransactionRuleFactory::create($user->company()->id, $user->id);
return $this->itemResponse($bank_transaction_rule); return $this->itemResponse($bank_transaction_rule);
} }
@ -347,8 +349,11 @@ class BankTransactionRuleController extends BaseController
*/ */
public function store(StoreBankTransactionRuleRequest $request) public function store(StoreBankTransactionRuleRequest $request)
{ {
//stub to store the model
$bank_transaction_rule = $this->bank_transaction_repo->save($request->all(), BankTransactionRuleFactory::create(auth()->user()->company()->id, auth()->user()->id, auth()->user()->account_id)); /** @var \App\Models\User $user **/
$user = auth()->user();
$bank_transaction_rule = $this->bank_transaction_repo->save($request->all(), BankTransactionRuleFactory::create($user->company()->id, $user->id));
return $this->itemResponse($bank_transaction_rule); return $this->itemResponse($bank_transaction_rule);
} }

View File

@ -27,7 +27,12 @@ class ContactHashLoginController extends Controller
public function login(string $contact_key) public function login(string $contact_key)
{ {
if (request()->has('subscription') && request()->subscription == 'true') { if (request()->has('subscription') && request()->subscription == 'true') {
$recurring_invoice = RecurringInvoice::where('client_id', auth()->guard('contact')->client->id)
/** @var \App\Models\ClientContact $client_contact **/
$client_contact = auth()->guard('contact');
/** @var \App\Models\RecurringInvoice $recurring_invoice **/
$recurring_invoice = RecurringInvoice::where('client_id', $client_contact->client->id)
->whereNotNull('subscription_id') ->whereNotNull('subscription_id')
->whereNull('deleted_at') ->whereNull('deleted_at')
->first(); ->first();

View File

@ -56,6 +56,7 @@ class DocumentController extends Controller
{ {
MultiDB::documentFindAndSetDb($document_hash); MultiDB::documentFindAndSetDb($document_hash);
/** @var \App\Models\Document $document **/
$document = Document::where('hash', $document_hash)->firstOrFail(); $document = Document::where('hash', $document_hash)->firstOrFail();
$headers = ['Cache-Control:' => 'no-cache']; $headers = ['Cache-Control:' => 'no-cache'];
@ -69,6 +70,7 @@ class DocumentController extends Controller
public function downloadMultiple(DownloadMultipleDocumentsRequest $request) public function downloadMultiple(DownloadMultipleDocumentsRequest $request)
{ {
/** @var \Illuminate\Database\Eloquent\Collection<Document> $documents **/
$documents = Document::whereIn('id', $this->transformKeys($request->file_hash)) $documents = Document::whereIn('id', $this->transformKeys($request->file_hash))
->where('company_id', auth()->guard('contact')->user()->company_id) ->where('company_id', auth()->guard('contact')->user()->company_id)
->get(); ->get();

View File

@ -212,7 +212,10 @@ class InvitationController extends Controller
public function paymentRouter(string $contact_key, string $payment_id) public function paymentRouter(string $contact_key, string $payment_id)
{ {
/** @var \App\Models\ClientContact $contact **/
$contact = ClientContact::withTrashed()->where('contact_key', $contact_key)->firstOrFail(); $contact = ClientContact::withTrashed()->where('contact_key', $contact_key)->firstOrFail();
/** @var \App\Models\Payment $payment **/
$payment = Payment::find($this->decodePrimaryKey($payment_id)); $payment = Payment::find($this->decodePrimaryKey($payment_id));
if ($payment->client_id != $contact->client_id) { if ($payment->client_id != $contact->client_id) {

View File

@ -97,13 +97,6 @@ class InvoiceController extends Controller
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle(); $file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle();
// $headers = ['Content-Type' => 'application/pdf'];
// $entity_string = $data['entity_type'];
// $file_name = $invitation->{$entity_string}->numberFormatter().'.pdf';
// return response()->streamDownload(function () use ($file) {
// echo $file;
// }, $file_name, $headers);
$headers = ['Content-Type' => 'application/pdf']; $headers = ['Content-Type' => 'application/pdf'];
return response()->make($file, 200, $headers); return response()->make($file, 200, $headers);

View File

@ -44,6 +44,8 @@ class NinjaPlanController extends Controller
if (! $company) { if (! $company) {
MultiDB::findAndSetDbByAccountKey($account_or_company_key); MultiDB::findAndSetDbByAccountKey($account_or_company_key);
/** @var \App\Models\Account $account **/
$account = Account::where('key', $account_or_company_key)->first(); $account = Account::where('key', $account_or_company_key)->first();
} else { } else {
$account = $company->account; $account = $company->account;

View File

@ -111,6 +111,7 @@ class PaymentController extends Controller
public function response(PaymentResponseRequest $request) public function response(PaymentResponseRequest $request)
{ {
/** @var \App\Models\CompanyGateway $gateway **/
$gateway = CompanyGateway::findOrFail($request->input('company_gateway_id')); $gateway = CompanyGateway::findOrFail($request->input('company_gateway_id'));
$payment_hash = PaymentHash::where('hash', $request->payment_hash)->firstOrFail(); $payment_hash = PaymentHash::where('hash', $request->payment_hash)->firstOrFail();
$invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id); $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id);

View File

@ -55,9 +55,13 @@ class PaymentMethodController extends Controller
$gateway = $this->getClientGateway(); $gateway = $this->getClientGateway();
$data['gateway'] = $gateway; $data['gateway'] = $gateway;
$data['client'] = auth()->user()->client;
/** @var \App\Models\ClientContact auth()->user() **/
$client_contact = auth()->user();
$data['client'] = $client_contact->client;
return $gateway return $gateway
->driver(auth()->user()->client) ->driver($client_contact->client)
->setPaymentMethod($request->query('method')) ->setPaymentMethod($request->query('method'))
->checkRequirements() ->checkRequirements()
->authorizeView($data); ->authorizeView($data);
@ -73,8 +77,11 @@ class PaymentMethodController extends Controller
{ {
$gateway = $this->getClientGateway(); $gateway = $this->getClientGateway();
/** @var \App\Models\ClientContact auth()->user() **/
$client_contact = auth()->user();
return $gateway return $gateway
->driver(auth()->user()->client) ->driver($client_contact->client)
->setPaymentMethod($request->query('method')) ->setPaymentMethod($request->query('method'))
->checkRequirements() ->checkRequirements()
->authorizeResponse($request); ->authorizeResponse($request);
@ -95,18 +102,23 @@ class PaymentMethodController extends Controller
public function verify(ClientGatewayToken $payment_method) public function verify(ClientGatewayToken $payment_method)
{ {
/** @var \App\Models\ClientContact auth()->user() **/
$client_contact = auth()->user();
return $payment_method->gateway return $payment_method->gateway
->driver(auth()->user()->client) ->driver($client_contact->client)
->setPaymentMethod(request()->query('method')) ->setPaymentMethod(request()->query('method'))
->verificationView($payment_method); ->verificationView($payment_method);
} }
public function processVerification(Request $request, ClientGatewaytoken $payment_method) public function processVerification(Request $request, ClientGatewaytoken $payment_method)
{ {
// $gateway = $this->getClientGateway(); /** @var \App\Models\ClientContact auth()->user() **/
$client_contact = auth()->user();
return $payment_method->gateway return $payment_method->gateway
->driver(auth()->user()->client) ->driver($client_contact->client)
->setPaymentMethod(request()->query('method')) ->setPaymentMethod(request()->query('method'))
->processVerification($request, $payment_method); ->processVerification($request, $payment_method);
} }
@ -119,9 +131,12 @@ class PaymentMethodController extends Controller
*/ */
public function destroy(ClientGatewayToken $payment_method) public function destroy(ClientGatewayToken $payment_method)
{ {
/** @var \App\Models\ClientContact auth()->user() **/
$client_contact = auth()->user();
if ($payment_method->gateway()->exists()) { if ($payment_method->gateway()->exists()) {
$payment_method->gateway $payment_method->gateway
->driver(auth()->user()->client) ->driver($client_contact->client)
->setPaymentMethod(request()->query('method')) ->setPaymentMethod(request()->query('method'))
->detach($payment_method); ->detach($payment_method);
} }
@ -143,15 +158,18 @@ class PaymentMethodController extends Controller
private function getClientGateway() private function getClientGateway()
{ {
/** @var \App\Models\ClientContact auth()->user() **/
$client_contact = auth()->user();
if (request()->query('method') == GatewayType::CREDIT_CARD) { if (request()->query('method') == GatewayType::CREDIT_CARD) {
return auth()->user()->client->getCreditCardGateway(); return $client_contact->client->getCreditCardGateway();
} }
if (request()->query('method') == GatewayType::BACS) { if (request()->query('method') == GatewayType::BACS) {
return auth()->user()->client->getBACSGateway(); return $client_contact->client->getBACSGateway();
} }
if (in_array(request()->query('method'), [GatewayType::BANK_TRANSFER, GatewayType::DIRECT_DEBIT, GatewayType::SEPA])) { if (in_array(request()->query('method'), [GatewayType::BANK_TRANSFER, GatewayType::DIRECT_DEBIT, GatewayType::SEPA])) {
return auth()->user()->client->getBankTransferGateway(); return $client_contact->client->getBankTransferGateway();
} }
abort(404, 'Gateway not found.'); abort(404, 'Gateway not found.');

View File

@ -50,8 +50,6 @@ class ProfileController extends Controller
$client_contact->save(); $client_contact->save();
// auth()->user()->fresh();
return back()->withSuccess( return back()->withSuccess(
ctrans('texts.profile_updated_successfully') ctrans('texts.profile_updated_successfully')
); );
@ -63,7 +61,7 @@ class ProfileController extends Controller
//update avatar if needed //update avatar if needed
if ($request->file('logo')) { if ($request->file('logo')) {
$path = (new UploadAvatar($request->file('logo'), auth()->user()->client->client_hash))->handle(); $path = (new UploadAvatar($request->file('logo'), $client->client_hash))->handle();
if ($path) { if ($path) {
$client->logo = $path; $client->logo = $path;

View File

@ -83,7 +83,7 @@ class QuoteController extends Controller
return $this->downloadQuotes((array) $transformed_ids); return $this->downloadQuotes((array) $transformed_ids);
} }
if ($request->action = 'approve') { if ($request->action == 'approve') {
return $this->approve((array) $transformed_ids, $request->has('process')); return $this->approve((array) $transformed_ids, $request->has('process'));
} }
@ -92,8 +92,11 @@ class QuoteController extends Controller
public function downloadQuotes($ids) public function downloadQuotes($ids)
{ {
/** @var \App\Models\ClientContact $client_contact **/
$client_contact = auth()->user();
$data['quotes'] = Quote::whereIn('id', $ids) $data['quotes'] = Quote::whereIn('id', $ids)
->whereClientId(auth()->user()->client->id) ->whereClientId($client_contact->client->id)
->withTrashed() ->withTrashed()
->get(); ->get();
@ -113,8 +116,12 @@ class QuoteController extends Controller
protected function downloadQuotePdf(array $ids) protected function downloadQuotePdf(array $ids)
{ {
/** @var \App\Models\ClientContact $client_contact **/
$client_contact = auth()->user();
$quotes = Quote::whereIn('id', $ids) $quotes = Quote::whereIn('id', $ids)
->whereClientId(auth()->user()->client->id) ->whereClientId($client_contact->client_id)
->withTrashed() ->withTrashed()
->get(); ->get();

View File

@ -30,7 +30,11 @@ class UploadController extends Controller
*/ */
public function __invoke(StoreUploadRequest $request) public function __invoke(StoreUploadRequest $request)
{ {
$this->saveDocuments($request->getFile(), auth()->user()->client, true);
/** @var \App\Models\ClientContact $client_contact **/
$client_contact = auth()->user();
$this->saveDocuments($request->getFile(), $client_contact->client, true);
return response([], 200); return response([], 200);
} }

View File

@ -547,6 +547,8 @@ class CompanyController extends BaseController
//If we are deleting the default companies, we'll need to make a new company the default. //If we are deleting the default companies, we'll need to make a new company the default.
if ($account->default_company_id == $company_id) { if ($account->default_company_id == $company_id) {
/** @var \App\Models\Company $new_default_company **/
$new_default_company = Company::whereAccountId($account->id)->first(); $new_default_company = Company::whereAccountId($account->id)->first();
$account->default_company_id = $new_default_company->id; $account->default_company_id = $new_default_company->id;
$account->save(); $account->save();
@ -560,7 +562,7 @@ class CompanyController extends BaseController
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param UploadCompanyRequest $request * @param UploadCompanyRequest $request
* @param Company $client * @param Company $company
* @return Response * @return Response
* *
* *
@ -622,7 +624,7 @@ class CompanyController extends BaseController
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param UploadCompanyRequest $request * @param DefaultCompanyRequest $request
* @param Company $company * @param Company $company
* @return Response * @return Response
* *

View File

@ -111,7 +111,10 @@ class CompanyUserController extends BaseController
*/ */
public function update(UpdateCompanyUserRequest $request, User $user) public function update(UpdateCompanyUserRequest $request, User $user)
{ {
$company = auth()->user()->company(); /** @var \App\Models\User $logged_in_user */
$logged_in_user = auth()->user();
$company = $logged_in_user->company();
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first(); $company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
@ -121,7 +124,7 @@ class CompanyUserController extends BaseController
return; return;
} }
if (auth()->user()->isAdmin()) { if ($logged_in_user->isAdmin()) {
$company_user->fill($request->input('company_user')); $company_user->fill($request->input('company_user'));
} else { } else {
$company_user->settings = $request->input('company_user')['settings']; $company_user->settings = $request->input('company_user')['settings'];
@ -136,7 +139,8 @@ class CompanyUserController extends BaseController
public function updatePreferences(UpdateCompanyUserPreferencesRequest $request, User $user) public function updatePreferences(UpdateCompanyUserPreferencesRequest $request, User $user)
{ {
/** @var \App\Models\User $logged_in_user */ /** @var \App\Models\User $logged_in_user */
$company = auth()->user()->company(); $logged_in_user = auth()->user();
$company = $logged_in_user->company();
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first(); $company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();

View File

@ -148,7 +148,10 @@ class CreditController extends BaseController
*/ */
public function create(CreateCreditRequest $request) public function create(CreateCreditRequest $request)
{ {
$credit = CreditFactory::create(auth()->user()->company()->id, auth()->user()->id); /** @var \App\Models\User $user**/
$user = auth()->user();
$credit = CreditFactory::create($user->company()->id, auth()->user()->id);
return $this->itemResponse($credit); return $this->itemResponse($credit);
} }
@ -193,9 +196,13 @@ class CreditController extends BaseController
*/ */
public function store(StoreCreditRequest $request) public function store(StoreCreditRequest $request)
{ {
$client = Client::find($request->input('client_id'));
$credit = $this->credit_repository->save($request->all(), CreditFactory::create(auth()->user()->company()->id, auth()->user()->id)); /** @var \App\Models\User $user**/
$user = auth()->user();
// $client = Client::find($request->input('client_id'));
$credit = $this->credit_repository->save($request->all(), CreditFactory::create($user->company()->id, $user->id));
$credit = $credit->service() $credit = $credit->service()
->fillDefaults() ->fillDefaults()
@ -207,7 +214,7 @@ class CreditController extends BaseController
$credit->client->service()->updatePaidToDate(-1 * $credit->balance)->save(); $credit->client->service()->updatePaidToDate(-1 * $credit->balance)->save();
} }
event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars($user->id)));
return $this->itemResponse($credit); return $this->itemResponse($credit);
} }
@ -383,7 +390,10 @@ class CreditController extends BaseController
->triggeredActions($request) ->triggeredActions($request)
->deletePdf(); ->deletePdf();
event(new CreditWasUpdated($credit, $credit->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); /** @var \App\Models\User $user**/
$user = auth()->user();
event(new CreditWasUpdated($credit, $credit->company, Ninja::eventVars($user->id)));
return $this->itemResponse($credit); return $this->itemResponse($credit);
} }
@ -495,9 +505,13 @@ class CreditController extends BaseController
*/ */
public function bulk(BulkCreditRequest $request) public function bulk(BulkCreditRequest $request)
{ {
/** @var \App\Models\User $user**/
$user = auth()->user();
$action = $request->input('action'); $action = $request->input('action');
if (Ninja::isHosted() && (stripos($action, 'email') !== false) && !auth()->user()->company()->account->account_sms_verified) { if (Ninja::isHosted() && (stripos($action, 'email') !== false) && !$user->company()->account->account_sms_verified) {
return response(['message' => 'Please verify your account to send emails.'], 400); return response(['message' => 'Please verify your account to send emails.'], 400);
} }
@ -515,20 +529,20 @@ class CreditController extends BaseController
*/ */
if ($action == 'bulk_download' && $credits->count() > 1) { if ($action == 'bulk_download' && $credits->count() > 1) {
$credits->each(function ($credit) { $credits->each(function ($credit) use($user){
if (auth()->user()->cannot('view', $credit)) { if ($user->cannot('view', $credit)) {
nlog('access denied'); nlog('access denied');
return response()->json(['message' => ctrans('text.access_denied')]); return response()->json(['message' => ctrans('text.access_denied')]);
} }
}); });
ZipCredits::dispatch($credits, $credits->first()->company, auth()->user()); ZipCredits::dispatch($credits, $credits->first()->company, $user);
return response()->json(['message' => ctrans('texts.sent_message')], 200); return response()->json(['message' => ctrans('texts.sent_message')], 200);
} }
if ($action == 'bulk_print' && auth()->user()->can('view', $credits->first())) { if ($action == 'bulk_print' && $user->can('view', $credits->first())) {
$paths = $credits->map(function ($credit) { $paths = $credits->map(function ($credit) {
return $credit->service()->getCreditPdf($credit->invitations->first()); return $credit->service()->getCreditPdf($credit->invitations->first());
}); });
@ -540,8 +554,8 @@ class CreditController extends BaseController
}, 'print.pdf', ['Content-Type' => 'application/pdf']); }, 'print.pdf', ['Content-Type' => 'application/pdf']);
} }
$credits->each(function ($credit, $key) use ($action) { $credits->each(function ($credit, $key) use ($action, $user) {
if (auth()->user()->can('edit', $credit)) { if ($user->can('edit', $credit)) {
$this->performAction($credit, $action, true); $this->performAction($credit, $action, true);
} }
}); });

View File

@ -111,7 +111,7 @@ class SendRecurring implements ShouldQueue
nlog("attempting to autobill {$invoice->number}"); nlog("attempting to autobill {$invoice->number}");
AutoBill::dispatch($invoice->id, $this->db, true)->delay(rand(1, 2)); AutoBill::dispatch($invoice->id, $this->db, true)->delay(rand(1, 2));
//edge case to support where online payment notifications are not enabled //04-08-2023 edge case to support where online payment notifications are not enabled
if(!$invoice->client->getSetting('client_online_payment_notification')){ if(!$invoice->client->getSetting('client_online_payment_notification')){
$this->sendRecurringEmails($invoice); $this->sendRecurringEmails($invoice);
} }
@ -120,7 +120,7 @@ class SendRecurring implements ShouldQueue
nlog("attempting to autobill {$invoice->number}"); nlog("attempting to autobill {$invoice->number}");
AutoBill::dispatch($invoice->id, $this->db, true)->delay(rand(1, 2)); AutoBill::dispatch($invoice->id, $this->db, true)->delay(rand(1, 2));
//edge case to support where online payment notifications are not enabled //04-08-2023 edge case to support where online payment notifications are not enabled
if(!$invoice->client->getSetting('client_online_payment_notification')) { if(!$invoice->client->getSetting('client_online_payment_notification')) {
$this->sendRecurringEmails($invoice); $this->sendRecurringEmails($invoice);
} }
@ -130,10 +130,16 @@ class SendRecurring implements ShouldQueue
$this->sendRecurringEmails($invoice); $this->sendRecurringEmails($invoice);
} }
} }
private function sendRecurringEmails(Invoice $invoice) /**
* Sends the recurring invoice emails to
* the designated contacts
*
* @param Invoice $invoice
* @return void
*/
private function sendRecurringEmails(Invoice $invoice): void
{ {
//Admin notification for recurring invoice sent. //Admin notification for recurring invoice sent.
if ($invoice->invitations->count() >= 1) { if ($invoice->invitations->count() >= 1) {

View File

@ -185,42 +185,42 @@ class Account extends BaseModel
return self::class; return self::class;
} }
public function users() public function users(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(User::class)->withTrashed(); return $this->hasMany(User::class)->withTrashed();
} }
public function default_company() public function default_company(): \Illuminate\Database\Eloquent\Relations\HasOne
{ {
return $this->hasOne(Company::class, 'id', 'default_company_id'); return $this->hasOne(Company::class, 'id', 'default_company_id');
} }
public function payment() public function payment(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Payment::class)->withTrashed(); return $this->belongsTo(Payment::class)->withTrashed();
} }
public function companies() public function companies(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Company::class); return $this->hasMany(Company::class);
} }
public function bank_integrations() public function bank_integrations(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(BankIntegration::class); return $this->hasMany(BankIntegration::class);
} }
public function company_users() public function company_users(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(CompanyUser::class); return $this->hasMany(CompanyUser::class);
} }
public function owner() public function owner(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(CompanyUser::class)->where('is_owner', true)->first() ? $this->hasMany(CompanyUser::class)->where('is_owner', true)->first()->user : false; return $this->hasMany(CompanyUser::class)->where('is_owner', true)->first() ? $this->hasMany(CompanyUser::class)->where('is_owner', true)->first()->user : false;
} }
public function tokens() public function tokens(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(CompanyToken::class)->withTrashed(); return $this->hasMany(CompanyToken::class)->withTrashed();
} }
@ -293,12 +293,12 @@ class Account extends BaseModel
} }
} }
public function isPaid() public function isPaid(): bool
{ {
return Ninja::isNinja() ? ($this->isPaidHostedClient() && ! $this->isTrial()) : $this->hasFeature(self::FEATURE_WHITE_LABEL); return Ninja::isNinja() ? ($this->isPaidHostedClient() && ! $this->isTrial()) : $this->hasFeature(self::FEATURE_WHITE_LABEL);
} }
public function isPaidHostedClient() public function isPaidHostedClient(): bool
{ {
if (! Ninja::isNinja()) { if (! Ninja::isNinja()) {
return false; return false;
@ -312,7 +312,7 @@ class Account extends BaseModel
return $this->plan == 'pro' || $this->plan == 'enterprise'; return $this->plan == 'pro' || $this->plan == 'enterprise';
} }
public function isFreeHostedClient() public function isFreeHostedClient(): bool
{ {
if (! Ninja::isNinja()) { if (! Ninja::isNinja()) {
return false; return false;
@ -325,7 +325,7 @@ class Account extends BaseModel
return $this->plan == 'free' || is_null($this->plan) || empty($this->plan); return $this->plan == 'free' || is_null($this->plan) || empty($this->plan);
} }
public function isEnterpriseClient() public function isEnterpriseClient(): bool
{ {
if (! Ninja::isNinja()) { if (! Ninja::isNinja()) {
return false; return false;
@ -334,7 +334,7 @@ class Account extends BaseModel
return $this->plan == 'enterprise'; return $this->plan == 'enterprise';
} }
public function isTrial() public function isTrial(): bool
{ {
if (! Ninja::isNinja()) { if (! Ninja::isNinja()) {
return false; return false;
@ -345,7 +345,7 @@ class Account extends BaseModel
return $plan_details && $plan_details['trial']; return $plan_details && $plan_details['trial'];
} }
public function startTrial($plan) public function startTrial($plan): void
{ {
if (! Ninja::isNinja()) { if (! Ninja::isNinja()) {
return; return;

View File

@ -11,22 +11,23 @@
namespace App\Models; namespace App\Models;
use App\Utils\Ninja;
use Illuminate\Support\Carbon;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesDates;
use App\Helpers\Invoice\InvoiceSum; use App\Helpers\Invoice\InvoiceSum;
use App\Helpers\Invoice\InvoiceSumInclusive;
use App\Jobs\Entity\CreateEntityPdf; use App\Jobs\Entity\CreateEntityPdf;
use App\Models\Presenters\CreditPresenter; use App\Utils\Traits\MakesReminders;
use App\Services\Credit\CreditService; use App\Services\Credit\CreditService;
use App\Services\Ledger\LedgerService; use App\Services\Ledger\LedgerService;
use App\Utils\Ninja;
use App\Utils\Traits\MakesDates;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesInvoiceValues;
use App\Utils\Traits\MakesReminders;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use App\Utils\Traits\MakesInvoiceValues;
use Laracasts\Presenter\PresentableTrait; use Laracasts\Presenter\PresentableTrait;
use App\Models\Presenters\CreditPresenter;
use App\Helpers\Invoice\InvoiceSumInclusive;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
/** /**
* App\Models\Credit * App\Models\Credit
@ -215,32 +216,32 @@ class Credit extends BaseModel
return $this->dateMutator($value); return $this->dateMutator($value);
} }
public function assigned_user() public function assigned_user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed(); return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
} }
public function vendor() public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Vendor::class); return $this->belongsTo(Vendor::class);
} }
public function history() public function history(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{ {
return $this->hasManyThrough(Backup::class, Activity::class); return $this->hasManyThrough(Backup::class, Activity::class);
} }
public function activities() public function activities(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(50); return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(50);
} }
public function company() public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Company::class); return $this->belongsTo(Company::class);
} }
public function user() public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(User::class)->withTrashed(); return $this->belongsTo(User::class)->withTrashed();
} }
@ -250,17 +251,12 @@ class Credit extends BaseModel
return $this->belongsTo(Client::class)->withTrashed(); return $this->belongsTo(Client::class)->withTrashed();
} }
// public function contacts() public function invitations(): \Illuminate\Database\Eloquent\Relations\HasMany
// {
// return $this->hasManyThrough(ClientContact::class, Client::class);
// }
public function invitations()
{ {
return $this->hasMany(CreditInvitation::class); return $this->hasMany(CreditInvitation::class);
} }
public function project() public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Project::class)->withTrashed(); return $this->belongsTo(Project::class)->withTrashed();
} }
@ -268,17 +264,17 @@ class Credit extends BaseModel
/** /**
* The invoice which the credit has been created from. * The invoice which the credit has been created from.
*/ */
public function invoice() public function invoice(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Invoice::class); return $this->belongsTo(Invoice::class);
} }
public function company_ledger() public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(CompanyLedger::class, 'company_ledgerable'); return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
} }
public function ledger() public function ledger(): \App\Services\Ledger\LedgerService
{ {
return new LedgerService($this); return new LedgerService($this);
} }
@ -287,17 +283,17 @@ class Credit extends BaseModel
* The invoice/s which the credit has * The invoice/s which the credit has
* been applied to. * been applied to.
*/ */
public function invoices() public function invoices(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(Invoice::class)->using(Paymentable::class); return $this->belongsToMany(Invoice::class)->using(Paymentable::class);
} }
public function payments() public function payments(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{ {
return $this->morphToMany(Payment::class, 'paymentable'); return $this->morphToMany(Payment::class, 'paymentable');
} }
public function documents() public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');
} }
@ -320,7 +316,7 @@ class Credit extends BaseModel
return $credit_calc->build(); return $credit_calc->build();
} }
public function service() public function service(): \App\Services\Credit\CreditService
{ {
return new CreditService($this); return new CreditService($this);
} }
@ -423,12 +419,12 @@ class Credit extends BaseModel
]; ];
} }
public function translate_entity() public function translate_entity(): string
{ {
return ctrans('texts.credit'); return ctrans('texts.credit');
} }
public static function stringStatus(int $status) public static function stringStatus(int $status): string
{ {
switch ($status) { switch ($status) {
case self::STATUS_DRAFT: case self::STATUS_DRAFT:

View File

@ -56,32 +56,6 @@ use Illuminate\Support\Facades\Storage;
* @method static \Illuminate\Database\Eloquent\Builder|Document onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Document onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Document query() * @method static \Illuminate\Database\Eloquent\Builder|Document query()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
* @method static \Illuminate\Database\Eloquent\Builder|Document whereAssignedUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereCompanyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereCustomValue1($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereCustomValue2($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereCustomValue3($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereCustomValue4($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereDisk($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereDocumentableId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereDocumentableType($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereHash($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereHeight($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereIsDefault($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereIsPublic($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document wherePreview($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereProjectId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereVendorId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document whereWidth($value)
* @method static \Illuminate\Database\Eloquent\Builder|Document withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Document withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Document withoutTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Document withoutTrashed()
* @mixin \Eloquent * @mixin \Eloquent

View File

@ -107,42 +107,27 @@ class InvoiceInvitation extends BaseModel
return Invoice::class; return Invoice::class;
} }
/** public function invoice(): \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return mixed
*/
public function invoice()
{ {
return $this->belongsTo(Invoice::class)->withTrashed(); return $this->belongsTo(Invoice::class)->withTrashed();
} }
/** public function getEntity(): \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return mixed
*/
public function getEntity()
{ {
return $this->belongsTo(Invoice::class)->withTrashed(); return $this->belongsTo(Invoice::class)->withTrashed();
} }
/** public function contact(): \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return mixed
*/
public function contact()
{ {
return $this->belongsTo(ClientContact::class, 'client_contact_id', 'id')->withTrashed(); return $this->belongsTo(ClientContact::class, 'client_contact_id', 'id')->withTrashed();
} }
/** public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return mixed
*/
public function user()
{ {
return $this->belongsTo(User::class)->withTrashed(); return $this->belongsTo(User::class)->withTrashed();
} }
/** public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return BelongsTo
*/
public function company()
{ {
return $this->belongsTo(Company::class); return $this->belongsTo(Company::class);
} }
@ -156,24 +141,24 @@ class InvoiceInvitation extends BaseModel
return sprintf('<img src="data:image/svg+xml;base64,%s"></img><p/>%s: %s', $this->signature_base64, ctrans('texts.signed'), $this->createClientDate($this->signature_date, $this->contact->client->timezone()->name)); return sprintf('<img src="data:image/svg+xml;base64,%s"></img><p/>%s: %s', $this->signature_base64, ctrans('texts.signed'), $this->createClientDate($this->signature_date, $this->contact->client->timezone()->name));
} }
public function getName() public function getName(): string
{ {
return $this->key; return $this->key;
} }
public function markViewed() public function markViewed(): void
{ {
$this->viewed_date = Carbon::now(); $this->viewed_date = Carbon::now();
$this->save(); $this->save();
} }
public function markOpened() public function markOpened(): void
{ {
$this->opened_date = Carbon::now(); $this->opened_date = Carbon::now();
$this->save(); $this->save();
} }
public function pdf_file_path() public function pdf_file_path(): string
{ {
$storage_path = Storage::url($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf'); $storage_path = Storage::url($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf');

View File

@ -283,7 +283,7 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->getCompany(); return $this->getCompany();
} }
public function company_users() public function company_users(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(CompanyUser::class)->withTrashed(); return $this->hasMany(CompanyUser::class)->withTrashed();
} }
@ -313,8 +313,6 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->token()->cu; return $this->token()->cu;
// return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'user_id', 'id', 'user_id')
// ->withTrashed();
} }
/** /**
@ -327,7 +325,7 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->company()->id; return $this->company()->id;
} }
public function clients() public function clients(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Client::class); return $this->hasMany(Client::class);
} }
@ -352,7 +350,6 @@ class User extends Authenticatable implements MustVerifyEmail
{ {
return json_decode($this->token()->cu->settings); return json_decode($this->token()->cu->settings);
//return json_decode($this->company_user->settings);
} }
/** /**
@ -364,14 +361,12 @@ class User extends Authenticatable implements MustVerifyEmail
{ {
return $this->token()->cu->is_admin; return $this->token()->cu->is_admin;
// return $this->company_user->is_admin;
} }
public function isOwner() : bool public function isOwner() : bool
{ {
return $this->token()->cu->is_owner; return $this->token()->cu->is_owner;
// return $this->company_user->is_owner;
} }
/** /**
@ -389,7 +384,7 @@ class User extends Authenticatable implements MustVerifyEmail
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function contacts() public function contacts(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(ClientContact::class); return $this->hasMany(ClientContact::class);
} }
@ -581,12 +576,12 @@ class User extends Authenticatable implements MustVerifyEmail
return false; return false;
} }
public function documents() public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');
} }
public function isVerified() public function isVerified(): bool
{ {
return is_null($this->email_verified_at) ? false : true; return is_null($this->email_verified_at) ? false : true;
} }

View File

@ -174,6 +174,8 @@ class WePayPaymentDriver extends BaseDriver
$config = $this->company_gateway->getConfig(); $config = $this->company_gateway->getConfig();
$accountId = $this->company_gateway->getConfigField('accountId'); $accountId = $this->company_gateway->getConfigField('accountId');
$objectId = false;
$objectType = '';
foreach (array_keys($input) as $key) { foreach (array_keys($input) as $key) {
if ('_id' == substr($key, -3)) { if ('_id' == substr($key, -3)) {
@ -183,7 +185,7 @@ class WePayPaymentDriver extends BaseDriver
} }
} }
if (! isset($objectType)) { if (! $objectId) {
throw new \Exception('Could not find object id parameter'); throw new \Exception('Could not find object id parameter');
} }
@ -226,12 +228,13 @@ class WePayPaymentDriver extends BaseDriver
return ['message' => 'Processed successfully']; return ['message' => 'Processed successfully'];
} elseif ($objectType == 'checkout') { } elseif ($objectType == 'checkout') {
/** @var \App\Models\Payment $payment */
$payment = Payment::where('company_id', $this->company_gateway->company_id) $payment = Payment::where('company_id', $this->company_gateway->company_id)
->where('transaction_reference', '=', $objectId) ->where('transaction_reference', '=', $objectId)
->first(); ->first();
if (! $payment) { if (! $payment) {
throw new Exception('Unknown payment'); throw new \Exception('Unknown payment');
} }
if ($payment->is_deleted) { if ($payment->is_deleted) {

View File

@ -38,9 +38,9 @@ class ActivityRepository extends BaseRepository
/** /**
* Save the Activity. * Save the Activity.
* *
* @param stdClass $fields The fields * @param \stdClass $fields The fields
* @param Collection $entity The entity that you wish to have backed up (typically Invoice, Quote etc etc rather than Payment) * @param \App\Models\Invoice | \App\Models\Quote | \App\Models\Credit | \App\Models\PurchaseOrder $entity
* @param $event_vars * @param array $event_vars
*/ */
public function save($fields, $entity, $event_vars) public function save($fields, $entity, $event_vars)
{ {
@ -69,8 +69,8 @@ class ActivityRepository extends BaseRepository
/** /**
* Creates a backup. * Creates a backup.
* *
* @param Collection $entity The entity * @param \App\Models\Invoice | \App\Models\Quote | \App\Models\Credit | \App\Models\PurchaseOrder $entity
* @param Collection $activity The activity * @param \App\Models\Activity $activity The activity
*/ */
public function createBackup($entity, $activity) public function createBackup($entity, $activity)
{ {
@ -98,6 +98,7 @@ class ActivityRepository extends BaseRepository
public function getTokenId(array $event_vars) public function getTokenId(array $event_vars)
{ {
if ($event_vars['token']) { if ($event_vars['token']) {
/** @var \App\Models\CompanyToken $company_token **/
$company_token = CompanyToken::where('token', $event_vars['token'])->first(); $company_token = CompanyToken::where('token', $event_vars['token'])->first();
if ($company_token) { if ($company_token) {

View File

@ -52,8 +52,9 @@ class UserRepository extends BaseRepository
if ($unset_company_user) { if ($unset_company_user) {
unset($details['company_user']); unset($details['company_user']);
} }
/** @var \App\Models\User $user */
$company = auth()->user()->company(); $user = auth()->user();
$company = $user->company();
$account = $company->account; $account = $company->account;
// if(array_key_exists('oauth_provider_id', $details)) // if(array_key_exists('oauth_provider_id', $details))