mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
v6 update
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Crater\Http\Resources;
|
||||
|
||||
use Crater\Models\CompanySetting;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CustomFieldValueResource extends JsonResource
|
||||
@ -28,6 +29,7 @@ class CustomFieldValueResource extends JsonResource
|
||||
'custom_field_id' => $this->custom_field_id,
|
||||
'company_id' => $this->company_id,
|
||||
'default_answer' => $this->defaultAnswer,
|
||||
'default_formatted_answer' => $this->dateTimeFormat(),
|
||||
'custom_field' => $this->when($this->customField()->exists(), function () {
|
||||
return new CustomFieldResource($this->customField);
|
||||
}),
|
||||
@ -36,4 +38,24 @@ class CustomFieldValueResource extends JsonResource
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
public function dateTimeFormat()
|
||||
{
|
||||
$key = getCustomFieldValueKey($this->type);
|
||||
|
||||
$answer = $this->default_answer;
|
||||
if (! $answer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($key == 'date_time_answer') {
|
||||
return $answer->format('Y-m-d H:i');
|
||||
}
|
||||
|
||||
if ($key == 'date_answer') {
|
||||
return $answer->format(CompanySetting::getSetting('carbon_date_format', $this->company_id));
|
||||
}
|
||||
|
||||
return $answer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user