diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 7efebce877b2..336706ea3668 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -545,7 +545,7 @@ class CreditController extends BaseController } }); - return $this->listResponse(Credit::withTrashed()->company()->whereIn('id', $request->ids)); + return $this->listResponse(Credit::with(['invitations','documents'])->withTrashed()->company()->whereIn('id', $request->ids)); } public function action(ActionCreditRequest $request, Credit $credit, $action) diff --git a/app/Http/Middleware/TokenAuth.php b/app/Http/Middleware/TokenAuth.php index 00858a707b0a..e73ccb00fcab 100644 --- a/app/Http/Middleware/TokenAuth.php +++ b/app/Http/Middleware/TokenAuth.php @@ -30,7 +30,10 @@ class TokenAuth */ public function handle($request, Closure $next) { - if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with(['user', 'company'])->where('token', $request->header('X-API-TOKEN'))->first())) { + if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with([ + 'user' => [ + 'account', + ], 'company'])->where('token', $request->header('X-API-TOKEN'))->first())) { $user = $company_token->user; $error = [ @@ -51,7 +54,6 @@ class TokenAuth return response()->json($error, 403); } - /* | | Necessary evil here: As we are authenticating on CompanyToken, @@ -59,7 +61,6 @@ class TokenAuth | us to decouple a $user and their attached companies completely. | */ - $truth = app()->make(TruthSource::class); $truth->setCompanyUser($company_token->cu); diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 953d2b2d89ca..e59a30da84e7 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -347,6 +347,10 @@ class RecurringInvoice extends BaseModel 'status', ]; + protected $with = [ + 'client.company', + ]; + protected $touches = []; public function getEntityType() diff --git a/app/Transformers/RecurringInvoiceTransformer.php b/app/Transformers/RecurringInvoiceTransformer.php index 5fcd576d89fe..5addf17b6aab 100644 --- a/app/Transformers/RecurringInvoiceTransformer.php +++ b/app/Transformers/RecurringInvoiceTransformer.php @@ -90,7 +90,6 @@ class RecurringInvoiceTransformer extends EntityTransformer 'po_number' => $invoice->po_number ?: '', 'date' => $invoice->date ?: '', 'last_sent_date' => $invoice->last_sent_date ?: '', - // 'next_send_date' => $invoice->next_send_date ?: '', 'next_send_date' => $invoice->next_send_date_client ?: '', 'due_date' => $invoice->due_date ?: '', 'terms' => $invoice->terms ?: '',