Fixes for returning company users when called from other routes

This commit is contained in:
David Bomba 2024-03-21 10:52:02 +11:00
parent dfb59a0d28
commit aa6153f571
6 changed files with 18 additions and 23 deletions

View File

@ -140,7 +140,7 @@ class TemplateEmail extends Mailable
'whitelabel' => $this->client->user->account->isPaid() ? true : false, 'whitelabel' => $this->client->user->account->isPaid() ? true : false,
'logo' => $this->company->present()->logo($settings), 'logo' => $this->company->present()->logo($settings),
'links' => $this->build_email->getAttachmentLinks(), 'links' => $this->build_email->getAttachmentLinks(),
'email_preferences' => (Ninja::isHosted() && in_array($settings->email_sending_method, ['default', 'mailgun'])) ? $this->company->domain() . URL::signedRoute('client.email_preferences', ['entity' => $this->invitation->getEntityString(), 'invitation_key' => $this->invitation->key], absolute: false) : false, 'email_preferences' => (Ninja::isHosted() && $this->invitation && in_array($settings->email_sending_method, ['default', 'mailgun'])) ? $this->company->domain() . URL::signedRoute('client.email_preferences', ['entity' => $this->invitation->getEntityString(), 'invitation_key' => $this->invitation->key], absolute: false) : false,
]); ]);
foreach ($this->build_email->getAttachments() as $file) { foreach ($this->build_email->getAttachments() as $file) {

View File

@ -698,7 +698,7 @@ class RecurringInvoice extends BaseModel
public function subscription(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function subscription(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Subscription::class); return $this->belongsTo(Subscription::class)->withTrashed();
} }
public function translate_entity() public function translate_entity()

View File

@ -41,6 +41,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $phone * @property string|null $phone
* @property string|null $private_notes * @property string|null $private_notes
* @property string|null $website * @property string|null $website
* @property string|null $routing_id
* @property bool $is_deleted * @property bool $is_deleted
* @property string|null $vat_number * @property string|null $vat_number
* @property string|null $transaction_name * @property string|null $transaction_name

View File

@ -579,6 +579,8 @@ class BaseDriver extends AbstractPaymentDriver
$nmo->company = $this->client->company; $nmo->company = $this->client->company;
$nmo->settings = $this->client->company->settings; $nmo->settings = $this->client->company->settings;
if($this->payment_hash)
{
$invoices = Invoice::query()->whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->withTrashed()->get(); $invoices = Invoice::query()->whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->withTrashed()->get();
$invoices->first()->invitations->each(function ($invitation) use ($nmo) { $invoices->first()->invitations->each(function ($invitation) use ($nmo) {
@ -587,6 +589,7 @@ class BaseDriver extends AbstractPaymentDriver
NinjaMailerJob::dispatch($nmo); NinjaMailerJob::dispatch($nmo);
} }
}); });
}
$message = [ $message = [
'server_response' => $response, 'server_response' => $response,

View File

@ -256,27 +256,15 @@ class PaytracePaymentDriver extends BaseDriver
{ {
$fields = parent::getClientRequiredFields(); $fields = parent::getClientRequiredFields();
nlog("a");
nlog($fields);
$fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required'];
$fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required'];
$fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required'];
$fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required'];
$fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required'];
nlog("b");
nlog($fields);
return $fields; return $fields;
} }
public function auth(): bool public function auth(): bool
{ {
try { try {

View File

@ -109,7 +109,10 @@ class UserTransformer extends EntityTransformer
$transformer = new CompanyUserTransformer($this->serializer); $transformer = new CompanyUserTransformer($this->serializer);
$cu = $user->company_users()->whereCompanyId($user->company_id)->first(); $cu = $user->company_users()->where('company_id',$user->company_id)->first();
if(!$cu)
return null;
return $this->includeItem($cu, $transformer, CompanyUser::class); return $this->includeItem($cu, $transformer, CompanyUser::class);
} }