From 89c264c6a98aeeb76133e7c0ead11a5815dfddce Mon Sep 17 00:00:00 2001 From: Mohit Panjwani Date: Tue, 25 May 2021 12:22:27 +0530 Subject: [PATCH] update implementation --- app/Models/Estimate.php | 7 +------ app/Models/Expense.php | 5 ----- app/Models/Invoice.php | 7 +------ app/Models/Payment.php | 7 +------ app/Models/User.php | 5 ----- app/Traits/HasCustomFieldsTrait.php | 4 ++-- 6 files changed, 5 insertions(+), 30 deletions(-) diff --git a/app/Models/Estimate.php b/app/Models/Estimate.php index 43b92b75..7afe7ffa 100644 --- a/app/Models/Estimate.php +++ b/app/Models/Estimate.php @@ -434,7 +434,7 @@ class Estimate extends Model implements HasMedia $estimateTemplate = EstimateTemplate::find($this->estimate_template_id); $company = Company::find($this->company_id); - $locale = CompanySetting::getSetting('language', $company->id); + $locale = CompanySetting::getSetting('language', $company->id); App::setLocale($locale); @@ -510,9 +510,4 @@ class Estimate extends Model implements HasMedia '{ESTIMATE_LINK}' => url('/customer/estimates/pdf/'.$this->unique_hash), ]; } - - public function getValues($slug) - { - return $this->getCustomFieldValues($slug); - } } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index e3764bbe..752c245c 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -219,9 +219,4 @@ class Expense extends Model implements HasMedia return true; } - - public function getValues($slug) - { - return $this->getCustomFieldValues($slug); - } } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 45c3dcf8..6445c12b 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -515,7 +515,7 @@ class Invoice extends Model implements HasMedia $invoiceTemplate = InvoiceTemplate::find($this->invoice_template_id); $company = Company::find($this->company_id); - $locale = CompanySetting::getSetting('language', $company->id); + $locale = CompanySetting::getSetting('language', $company->id); App::setLocale($locale); @@ -591,9 +591,4 @@ class Invoice extends Model implements HasMedia '{INVOICE_LINK}' => url('/customer/invoices/pdf/'.$this->unique_hash), ]; } - - public function getValues($slug) - { - return $this->getCustomFieldValues($slug); - } } diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 65e7f25e..645238d1 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -380,7 +380,7 @@ class Payment extends Model implements HasMedia public function getPDFData() { $company = Company::find($this->company_id); - $locale = CompanySetting::getSetting('language', $company->id); + $locale = CompanySetting::getSetting('language', $company->id); \App::setLocale($locale); @@ -446,9 +446,4 @@ class Payment extends Model implements HasMedia '{PAYMENT_LINK}' => $this->paymentPdfUrl, ]; } - - public function getValues($slug) - { - return $this->getCustomFieldValues($slug); - } } diff --git a/app/Models/User.php b/app/Models/User.php index b3f2484d..95307a92 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -422,9 +422,4 @@ class User extends Authenticatable implements HasMedia return $companySettings; } - - public function getValues($slug) - { - return $this->getCustomFieldValues($slug); - } } diff --git a/app/Traits/HasCustomFieldsTrait.php b/app/Traits/HasCustomFieldsTrait.php index 7617f16c..cf370104 100644 --- a/app/Traits/HasCustomFieldsTrait.php +++ b/app/Traits/HasCustomFieldsTrait.php @@ -43,9 +43,9 @@ trait HasCustomFieldsTrait } } - public function getCustomFieldValues($slug) + public function getCustomFieldBySlug($slug) { - return $this->fields()->whereHas('customField', function ($query) use ($slug) { + return $this->fields()->with('customField')->whereHas('customField', function ($query) use ($slug) { $query->where('slug', $slug); })->first(); }