From 9652e3bdf58265d3a623b0459a01e514a9731da3 Mon Sep 17 00:00:00 2001 From: harshjagad20 Date: Sat, 18 Dec 2021 12:43:20 +0530 Subject: [PATCH] fix parse condition --- app/Models/CustomField.php | 2 +- app/Models/CustomFieldValue.php | 2 +- app/Models/Estimate.php | 4 ++-- app/Models/Expense.php | 2 +- app/Models/Invoice.php | 4 ++-- app/Models/Payment.php | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index e9902d39..871f7278 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -25,7 +25,7 @@ class CustomField extends Model public function setDateAnswerAttribute($value) { if ($value && $value != null) { - $this->attributes['date_answer'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['date_answer'] = Carbon::parse($value)->format('Y-m-d'); } } diff --git a/app/Models/CustomFieldValue.php b/app/Models/CustomFieldValue.php index 2a862425..2b593a3a 100644 --- a/app/Models/CustomFieldValue.php +++ b/app/Models/CustomFieldValue.php @@ -21,7 +21,7 @@ class CustomFieldValue extends Model public function setDateAnswerAttribute($value) { if ($value && $value != null) { - $this->attributes['date_answer'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['date_answer'] = Carbon::parse($value)->format('Y-m-d'); } } diff --git a/app/Models/Estimate.php b/app/Models/Estimate.php index deaf1aa8..78f8c56d 100644 --- a/app/Models/Estimate.php +++ b/app/Models/Estimate.php @@ -57,14 +57,14 @@ class Estimate extends Model implements HasMedia public function setEstimateDateAttribute($value) { if ($value) { - $this->attributes['estimate_date'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['estimate_date'] = Carbon::parse($value)->format('Y-m-d'); } } public function setExpiryDateAttribute($value) { if ($value) { - $this->attributes['expiry_date'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['expiry_date'] = Carbon::parse($value)->format('Y-m-d'); } } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 93405dd5..21326058 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -33,7 +33,7 @@ class Expense extends Model implements HasMedia public function setExpenseDateAttribute($value) { if ($value) { - $this->attributes['expense_date'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['expense_date'] = Carbon::parse($value)->format('Y-m-d'); } } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index e683c107..f7133036 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -64,14 +64,14 @@ class Invoice extends Model implements HasMedia public function setInvoiceDateAttribute($value) { if ($value) { - $this->attributes['invoice_date'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['invoice_date'] = Carbon::parse($value)->format('Y-m-d'); } } public function setDueDateAttribute($value) { if ($value) { - $this->attributes['due_date'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['due_date'] = Carbon::parse($value)->format('Y-m-d'); } } diff --git a/app/Models/Payment.php b/app/Models/Payment.php index d88030d9..b7a751e1 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -57,7 +57,7 @@ class Payment extends Model implements HasMedia public function setPaymentDateAttribute($value) { if ($value) { - $this->attributes['payment_date'] = Carbon::createFromFormat('Y-m-d', $value); + $this->attributes['payment_date'] = Carbon::parse($value)->format('Y-m-d'); } }