diff --git a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php index e4fa23a7f03f..d610d4515f82 100644 --- a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php +++ b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php @@ -64,7 +64,7 @@ class RecurringInvoiceController extends Controller { nlog('outside cancellation'); - if (optional($recurring_invoice->subscription)->allow_cancellation) { + if ($recurring_invoice->subscription?->allow_cancellation) { nlog('inside the cancellation'); $nmo = new NinjaMailerObject; diff --git a/app/PaymentDrivers/Braintree/ACH.php b/app/PaymentDrivers/Braintree/ACH.php index bb209833cae1..86995790d8ab 100644 --- a/app/PaymentDrivers/Braintree/ACH.php +++ b/app/PaymentDrivers/Braintree/ACH.php @@ -62,7 +62,7 @@ class ACH implements MethodInterface ], ]); - if ($result->success && optional($result->paymentMethod)->verified) { + if ($result->success && $result->paymentMethod?->verified) { $account = $result->paymentMethod; try { diff --git a/app/PaymentDrivers/Sample/resources/pay.blade.php b/app/PaymentDrivers/Sample/resources/pay.blade.php index 4f8841bca6bb..ea05015e1c90 100644 --- a/app/PaymentDrivers/Sample/resources/pay.blade.php +++ b/app/PaymentDrivers/Sample/resources/pay.blade.php @@ -25,7 +25,7 @@ data-token="{{ $token->token }}" name="payment-type" class="form-radio cursor-pointer toggle-payment-with-token"/> - **** {{ optional($token->meta)->last4 }} + **** {{ $token->meta?->last4 }} @endforeach @endisset diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 894038a52cf4..9912a86d5639 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -247,7 +247,7 @@ class Design extends BaseDesign ['element' => 'span', 'content' => "{$this->client->shipping_state} ", 'properties' => ['ref' => 'delivery_note-client.shipping_state']], ['element' => 'span', 'content' => "{$this->client->shipping_postal_code} ", 'properties' => ['ref' => 'delivery_note-client.shipping_postal_code']], ]], - ['element' => 'p', 'content' => optional($this->client->shipping_country)->name, 'show_empty' => false], + ['element' => 'p', 'content' => $this->client->shipping_country?->name, 'show_empty' => false], ]; if (! is_null($this->context['contact'])) { diff --git a/app/Utils/ClientPortal/CustomMessage/CustomMessage.php b/app/Utils/ClientPortal/CustomMessage/CustomMessage.php index abc380542218..d1737d583f40 100644 --- a/app/Utils/ClientPortal/CustomMessage/CustomMessage.php +++ b/app/Utils/ClientPortal/CustomMessage/CustomMessage.php @@ -87,57 +87,57 @@ class CustomMessage private function compose(): array { return [ - '$company.id' => optional($this->company)->id, - '$company.name' => optional($this->company)->getSetting('name'), - '$company.website' => optional($this->company)->getSetting('website'), + '$company.id' => $this->company?->id, + '$company.name' => $this->company?->getSetting('name'), + '$company.website' => $this->company?->getSetting('website'), - '$client.id' => optional($this->client)->id, - '$client.name' => optional($this->client)->name, - '$client.website' => optional($this->client)->website, - '$client.public_notes' => optional($this->client)->public_notes, - '$client.phone' => optional($this->client)->phone, - '$client.balance' => optional($this->client)->balance, - '$client.address1' => optional(optional($this->client)->present())->address1, - '$client.address2' => optional(optional($this->client)->present())->address2, - '$client.city' => optional(optional($this->client)->present())->city, - '$client.state' => optional(optional($this->client)->present())->state, - '$client.postal_code' => optional(optional($this->client)->present())->postal_code, - '$client.country' => optional(optional(optional($this->client)->present())->country)->full_name, - '$client.address' => optional(optional($this->client)->present())->address(), - '$client.shipping_address' => optional(optional($this->client)->present())->shipping_address(), - '$client.primary_contact_name' => optional(optional($this->client)->present())->primary_contact_name(), - '$client.city_state' => optional(optional($this->client)->present())->getCityState(), + '$client.id' => $this->client?->id, + '$client.name' => $this->client?->name, + '$client.website' => $this->client?->website, + '$client.public_notes' => $this->client?->public_notes, + '$client.phone' => $this->client?->phone, + '$client.balance' => $this->client?->balance, + '$client.address1' => $this->client?->present()?->address1, + '$client.address2' => $this->client?->present()?->address2, + '$client.city' => $this->client?->present()?->city, + '$client.state' => $this->client?->present()?->state, + '$client.postal_code' => $this->client?->present()?->postal_code, + '$client.country' => $this->client?->present()?->country?->full_name, + '$client.address' => $this->client?->present()?->address(), + '$client.shipping_address' => $this->client?->present()?->shipping_address(), + '$client.primary_contact_name' => $this->client?->present()?->primary_contact_name(), + '$client.city_state' => $this->client?->present()?->getCityState(), - '$contact.first_name' => optional($this->contact)->first_name, - '$contact.last_name' => optional($this->contact)->last_name, - '$contact.phone' => optional($this->contact)->phone, - '$contact.email' => optional($this->contact)->email, - '$contact.avatar' => optional($this->contact)->avatar, + '$contact.first_name' => $this->contact?->first_name, + '$contact.last_name' => $this->contact?->last_name, + '$contact.phone' => $this->contact?->phone, + '$contact.email' => $this->contact?->email, + '$contact.avatar' => $this->contact?->avatar, - '$group.id' => optional($this->group)->id, + '$group.id' => $this->group?->id, - '$entity.id' => optional($this->entity)->hashed_id, - '$entity.number' => optional($this->entity)->number, - '$entity.discount' => optional($this->entity)->discount, - '$entity.date' => optional($this->entity)->date, // Todo: Handle formatDate - '$entity.due_date' => optional($this->entity)->due_date, // Todo: Handle formatDate - '$entity.last_sent_date' => optional($this->entity)->last_sent_date, - '$entity.public_notes' => optional($this->entity)->public_notes, - '$entity.terms' => optional($this->entity)->terms, - '$entity.amount' => optional($this->entity)->amount, // Todo: Handle moneyformat - '$entity.balance' => optional($this->entity)->balance, // Todo: Handle moneyformat - '$entity.created_at' => optional($this->entity)->created_at, // Todo: Handle formatDate + '$entity.id' => $this->entity?->hashed_id, + '$entity.number' => $this->entity?->number, + '$entity.discount' => $this->entity?->discount, + '$entity.date' => $this->entity?->date, // Todo: Handle formatDate + '$entity.due_date' => $this->entity?->due_date, // Todo: Handle formatDate + '$entity.last_sent_date' => $this->entity?->last_sent_date, + '$entity.public_notes' => $this->entity?->public_notes, + '$entity.terms' => $this->entity?->terms, + '$entity.amount' => $this->entity?->amount, // Todo: Handle moneyformat + '$entity.balance' => $this->entity?->balance, // Todo: Handle moneyformat + '$entity.created_at' => $this->entity?->created_at, // Todo: Handle formatDate - '$entity.status' => optional(optional($this->entity))->badgeForStatus(optional($this->entity)->status_id), // It would be nice if we have method that will only return status as text, not with markup. - '$entity.project' => optional(optional($this->entity)->project)->name, - '$entity.project.date' => optional(optional($this->entity)->project)->date, + '$entity.status' => optional(optional($this->entity))->badgeForStatus($this->entity?->status_id), // It would be nice if we have method that will only return status as text, not with markup. + '$entity.project' => $this->entity?->project?->name, + '$entity.project.date' => $this->entity?->project?->date, - '$invitation.id' => optional($this->invitation)->id, - '$invitation.user.first_name' => optional(optional($this->invitation)->user)->first_name, - '$invitation.user.last_name' => optional(optional($this->invitation)->user)->last_name, - '$invitation.sent_date' => optional($this->invitation)->sent_date, // Todo: Handle formatDate - '$invitation.viewed_date' => optional($this->invitation)->viewed_date, // Todo: Handle formatDate, - '$invitation.opened_date' => optional($this->invitation)->opened_date, // Todo: Handle formatDate, + '$invitation.id' => $this->invitation?->id, + '$invitation.user.first_name' => $this->invitation?->user?->first_name, + '$invitation.user.last_name' => $this->invitation?->user?->last_name, + '$invitation.sent_date' => $this->invitation?->sent_date, // Todo: Handle formatDate + '$invitation.viewed_date' => $this->invitation?->viewed_date, // Todo: Handle formatDate, + '$invitation.opened_date' => $this->invitation?->opened_date, // Todo: Handle formatDate, ]; } } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 0fcde20b901b..c17462fb976a 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -372,7 +372,7 @@ class HtmlEngine $data['$client.currency'] = ['value' => $this->client->currency()->code, 'label' => '']; - $data['$client.lang_2'] = ['value' => optional($this->client->language())->locale, 'label' => '']; + $data['$client.lang_2'] = ['value' => $this->client->language()?->locale, 'label' => '']; $data['$client.balance'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')]; $data['$client_balance'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')]; @@ -520,8 +520,8 @@ class HtmlEngine $data['$payment_url'] = &$data['$payment_link']; $data['$portalButton'] = &$data['$paymentLink']; - $data['$dir'] = ['value' => optional($this->client->language())->locale === 'ar' ? 'rtl' : 'ltr', 'label' => '']; - $data['$dir_text_align'] = ['value' => optional($this->client->language())->locale === 'ar' ? 'right' : 'left', 'label' => '']; + $data['$dir'] = ['value' => $this->client->language()?->locale === 'ar' ? 'rtl' : 'ltr', 'label' => '']; + $data['$dir_text_align'] = ['value' => $this->client->language()?->locale === 'ar' ? 'right' : 'left', 'label' => '']; $data['$payment.date'] = ['value' => ' ', 'label' => ctrans('texts.payment_date')]; $data['$method'] = ['value' => ' ', 'label' => ctrans('texts.method')]; diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index 3b1836f99ef4..d4697a560b1e 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -290,9 +290,9 @@ trait MakesInvoiceValues $helpers = new Helpers(); $_table_type = ltrim($table_type, '$'); // From $product -> product. - $data[$key][$table_type.'.product_key'] = is_null(optional($item)->product_key) ? $item->item : $item->product_key; - $data[$key][$table_type.'.item'] = is_null(optional($item)->item) ? $item->product_key : $item->item; - $data[$key][$table_type.'.service'] = is_null(optional($item)->service) ? $item->product_key : $item->service; + $data[$key][$table_type.'.product_key'] = is_null($item?->product_key) ? $item->item : $item->product_key; + $data[$key][$table_type.'.item'] = is_null($item?->item) ? $item->product_key : $item->item; + $data[$key][$table_type.'.service'] = is_null($item?->service) ? $item->product_key : $item->service; $data[$key][$table_type.'.notes'] = Helpers::processReservedKeywords($item->notes, $entity); $data[$key][$table_type.'.description'] = Helpers::processReservedKeywords($item->notes, $entity); @@ -354,7 +354,7 @@ trait MakesInvoiceValues $data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3']; } - $data[$key]['task_id'] = optional($item)->task_id; + $data[$key]['task_id'] = $item?->task_id; } return $data; diff --git a/app/Utils/VendorHtmlEngine.php b/app/Utils/VendorHtmlEngine.php index f1b305989731..e924d53cdaed 100644 --- a/app/Utils/VendorHtmlEngine.php +++ b/app/Utils/VendorHtmlEngine.php @@ -383,8 +383,8 @@ class VendorHtmlEngine $data['$autoBill'] = ['value' => ctrans('texts.auto_bill_notification_placeholder'), 'label' => '']; $data['$auto_bill'] = &$data['$autoBill']; - $data['$dir'] = ['value' => optional($this->company->language())->locale === 'ar' ? 'rtl' : 'ltr', 'label' => '']; - $data['$dir_text_align'] = ['value' => optional($this->company->language())->locale === 'ar' ? 'right' : 'left', 'label' => '']; + $data['$dir'] = ['value' => $this->company->language()?->locale === 'ar' ? 'rtl' : 'ltr', 'label' => '']; + $data['$dir_text_align'] = ['value' => $this->company->language()?->locale === 'ar' ? 'right' : 'left', 'label' => '']; $data['$payment.date'] = ['value' => ' ', 'label' => ctrans('texts.payment_date')]; $data['$method'] = ['value' => ' ', 'label' => ctrans('texts.method')]; diff --git a/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php b/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php index 0faa5f515c48..0b4935d0a565 100644 --- a/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php @@ -70,7 +70,7 @@ {{ App\Models\GatewayType::getAlias($payment_method->gateway_type_id) }}