mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
add new makeCustomField (centralised refactor)
This commit is contained in:
parent
ebfbfb6e10
commit
491d080ab4
@ -40,16 +40,16 @@ class Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A centralised way to format the custom fields content.
|
* A centralised method to format the custom fields content.
|
||||||
*
|
*
|
||||||
* @param mixed $custom_fields
|
* @param mixed|null $custom_fields
|
||||||
* @param mixed $field
|
* @param mixed $field
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param \App\Models\Client|null $client
|
* @param \App\Models\Client|null $client
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public function formatCustomFieldValue($custom_fields, $field, $value, Client $client = null): ?string
|
public function formatCustomFieldValue($custom_fields = null, $field, $value, Client $client = null): ?string
|
||||||
{
|
{
|
||||||
$custom_field = '';
|
$custom_field = '';
|
||||||
|
|
||||||
@ -76,4 +76,24 @@ class Helpers
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A centralised method to make custom field.
|
||||||
|
* @param mixed|null $custom_fields
|
||||||
|
* @param mixed $field
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function makeCustomField($custom_fields = null, $field): string
|
||||||
|
{
|
||||||
|
if ($custom_fields && property_exists($custom_fields, $field)) {
|
||||||
|
$custom_field = $custom_fields->{$field};
|
||||||
|
|
||||||
|
$custom_field_parts = explode('|', $custom_field);
|
||||||
|
|
||||||
|
return $custom_field_parts[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user