Skip to content

Commit

Permalink
Document and Transaction trait getSettingKey function replace get{Doc…
Browse files Browse the repository at this point in the history
…ument/Transaction}SettingKey
  • Loading branch information
cuneytsenturk committed Apr 12, 2023
1 parent a084f83 commit ee5822f
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 84 deletions.
54 changes: 27 additions & 27 deletions app/Abstracts/View/Components/Documents/Form.php
Expand Up @@ -763,7 +763,7 @@ protected function getDueAt($type, $document, $dueAt)
$issuedAt = Date::now()->toDateString();
}

$addDays = setting($this->getSettingKey($type, 'payment_terms'), 0) ?: 0;
$addDays = setting($this->getDocumentSettingKey($type, 'payment_terms'), 0) ?: 0;

$dueAt = Date::parse($issuedAt)->addDays($addDays)->toDateString();

Expand Down Expand Up @@ -875,7 +875,7 @@ protected function getHideItemName($type, $hideItemName): bool
return $hideItemName;
}

$hideItemName = setting($this->getSettingKey($type, 'item_name'), false);
$hideItemName = setting($this->getDocumentSettingKey($type, 'item_name'), false);

// if you use settting translation
if ($hideItemName === 'hide') {
Expand All @@ -898,18 +898,18 @@ protected function getTextItemName($type, $textItemName)
}

// if you use settting translation
if (setting($this->getSettingKey($type, 'item_name'), 'items') === 'custom') {
if (empty($textItemName = setting($this->getSettingKey($type, 'item_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'item_name'), 'items') === 'custom') {
if (empty($textItemName = setting($this->getDocumentSettingKey($type, 'item_name_input')))) {
$textItemName = 'general.items';
}

return $textItemName;
}

if (setting($this->getSettingKey($type, 'item_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'item_name'))) != setting($this->getSettingKey($type, 'item_name')))
if (setting($this->getDocumentSettingKey($type, 'item_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'item_name'))) != setting($this->getDocumentSettingKey($type, 'item_name')))
) {
return setting($this->getSettingKey($type, 'item_name'));
return setting($this->getDocumentSettingKey($type, 'item_name'));
}

$translation = $this->getTextFromConfig($type, 'items');
Expand All @@ -930,7 +930,7 @@ protected function getHideItemDescription($type, $hideItemDescription): bool


// if you use settting translation
if (setting($this->getSettingKey($type, 'hide_item_description'), false)) {
if (setting($this->getDocumentSettingKey($type, 'hide_item_description'), false)) {
return true;
}

Expand Down Expand Up @@ -964,7 +964,7 @@ protected function getHideItemQuantity($type, $hideItemQuantity): bool
return $hideItemQuantity;
}

$hideItemQuantity = setting($this->getSettingKey($type, 'quantity_name'), false);
$hideItemQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name'), false);

// if you use settting translation
if ($hideItemQuantity === 'hide') {
Expand All @@ -987,18 +987,18 @@ protected function getTextItemQuantity($type, $textItemQuantity)
}

// if you use settting translation
if (setting($this->getSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textItemQuantity = setting($this->getSettingKey($type, 'quantity_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textItemQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name_input')))) {
$textItemQuantity = 'invoices.quantity';
}

return $textItemQuantity;
}

if (setting($this->getSettingKey($type, 'quantity_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'quantity_name'))) != setting($this->getSettingKey($type, 'quantity_name')))
if (setting($this->getDocumentSettingKey($type, 'quantity_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'quantity_name'))) != setting($this->getDocumentSettingKey($type, 'quantity_name')))
) {
return setting($this->getSettingKey($type, 'quantity_name'));
return setting($this->getDocumentSettingKey($type, 'quantity_name'));
}

$translation = $this->getTextFromConfig($type, 'quantity');
Expand All @@ -1016,7 +1016,7 @@ protected function getHideItemPrice($type, $hideItemPrice): bool
return $hideItemPrice;
}

$hideItemPrice = setting($this->getSettingKey($type, 'price_name'), false);
$hideItemPrice = setting($this->getDocumentSettingKey($type, 'price_name'), false);

// if you use settting translation
if ($hideItemPrice === 'hide') {
Expand All @@ -1039,18 +1039,18 @@ protected function getTextItemPrice($type, $textItemPrice)
}

// if you use settting translation
if (setting($this->getSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textItemPrice = setting($this->getSettingKey($type, 'price_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textItemPrice = setting($this->getDocumentSettingKey($type, 'price_name_input')))) {
$textItemPrice = 'invoices.price';
}

return $textItemPrice;
}

if (setting($this->getSettingKey($type, 'price_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'price_name'))) != setting($this->getSettingKey($type, 'price_name')))
if (setting($this->getDocumentSettingKey($type, 'price_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'price_name'))) != setting($this->getDocumentSettingKey($type, 'price_name')))
) {
return setting($this->getSettingKey($type, 'price_name'));
return setting($this->getDocumentSettingKey($type, 'price_name'));
}

$translation = $this->getTextFromConfig($type, 'price');
Expand All @@ -1069,7 +1069,7 @@ protected function getHideItemAmount($type, $hideItemAmount): bool
}

// if you use settting translation
if (setting($this->getSettingKey($type, 'hide_amount'), false)) {
if (setting($this->getDocumentSettingKey($type, 'hide_amount'), false)) {
return true;
}

Expand Down Expand Up @@ -1104,7 +1104,7 @@ protected function getHideDiscount($type, $hideDiscount)
}

// if you use settting translation
if ($hideDiscount = setting($this->getSettingKey($type, 'hide_discount'), false)) {
if ($hideDiscount = setting($this->getDocumentSettingKey($type, 'hide_discount'), false)) {
return $hideDiscount;
}

Expand All @@ -1125,7 +1125,7 @@ protected function getSearchCharLimit($type, $searchCharLimit)
}

// if you use settting translation
if ($settingCharLimit = setting($this->getSettingKey($type, 'item_search_chart_limit'), false)) {
if ($settingCharLimit = setting($this->getDocumentSettingKey($type, 'item_search_chart_limit'), false)) {
return $settingCharLimit;
}

Expand All @@ -1149,7 +1149,7 @@ protected function getNotesValue($notes)
return $this->document->notes;
}

return setting($this->getSettingKey($this->type, 'notes'));
return setting($this->getDocumentSettingKey($this->type, 'notes'));
}

protected function getTextSectionAdvancedTitle($type, $textSectionAdvancedTitle)
Expand All @@ -1176,7 +1176,7 @@ protected function getTitleSettingValue($type, $titleSetting)
return $titleSetting;
}

return setting($this->getSettingKey($type, 'title'));
return setting($this->getDocumentSettingKey($type, 'title'));
}

protected function getSubheadingSettingValue($type, $subheadingSetting)
Expand All @@ -1185,7 +1185,7 @@ protected function getSubheadingSettingValue($type, $subheadingSetting)
return $subheadingSetting;
}

return setting($this->getSettingKey($type, 'subheading'));
return setting($this->getDocumentSettingKey($type, 'subheading'));
}

protected function getFooterValue($footer)
Expand All @@ -1198,7 +1198,7 @@ protected function getFooterValue($footer)
return $this->document->footer;
}

return setting($this->getSettingKey($this->type, 'footer'));
return setting($this->getDocumentSettingKey($this->type, 'footer'));
}

protected function getTypeCategory($type, $typeCategory)
Expand Down
32 changes: 16 additions & 16 deletions app/Abstracts/View/Components/Documents/Show.php
Expand Up @@ -909,7 +909,7 @@ protected function getDocumentTemplate($type, $documentTemplate)
return $template;
}

$documentTemplate = setting($this->getSettingKey($type, 'template'), 'default');
$documentTemplate = setting($this->getDocumentSettingKey($type, 'template'), 'default');

return $documentTemplate;
}
Expand Down Expand Up @@ -975,7 +975,7 @@ protected function getBackgroundColor($type, $backgroundColor)
}

// checking setting color
$key = $this->getSettingKey($type, 'color');
$key = $this->getDocumentSettingKey($type, 'color');

if (! empty(setting($key))) {
$backgroundColor = setting($key);
Expand All @@ -1000,7 +1000,7 @@ protected function getTextDocumentTitle($type, $textDocumentTitle)
return $textDocumentTitle;
}

$key = $this->getSettingKey($type, 'title');
$key = $this->getDocumentSettingKey($type, 'title');

if (! empty(setting($key))) {
return setting($key);
Expand All @@ -1021,7 +1021,7 @@ protected function getTextDocumentSubheading($type, $textDocumentSubheading)
return $textDocumentSubheading;
}

$key = $this->getSettingKey($type, 'subheading');
$key = $this->getDocumentSettingKey($type, 'subheading');

if (!empty(setting($key))) {
return setting($key);
Expand Down Expand Up @@ -1151,8 +1151,8 @@ protected function getTextItems($type, $textItems)
}

// if you use settting translation
if (setting($this->getSettingKey($type, 'item_name'), 'items') == 'custom') {
if (empty($textItems = setting($this->getSettingKey($type, 'item_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'item_name'), 'items') == 'custom') {
if (empty($textItems = setting($this->getDocumentSettingKey($type, 'item_name_input')))) {
$textItems = 'general.items';
}

Expand All @@ -1175,8 +1175,8 @@ protected function getTextQuantity($type, $textQuantity)
}

// if you use settting translation
if (setting($this->getSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textQuantity = setting($this->getSettingKey($type, 'quantity_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name_input')))) {
$textQuantity = 'invoices.quantity';
}

Expand All @@ -1199,8 +1199,8 @@ protected function getTextPrice($type, $textPrice)
}

// if you use settting translation
if (setting($this->getSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textPrice = setting($this->getSettingKey($type, 'price_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textPrice = setting($this->getDocumentSettingKey($type, 'price_name_input')))) {
$textPrice = 'invoices.price';
}

Expand Down Expand Up @@ -1255,7 +1255,7 @@ protected function getHideName($type, $hideName)
}

// if you use settting translation
if ($hideName = setting($this->getSettingKey($type, 'item_name'), false) && $hideName == 'hide') {
if ($hideName = setting($this->getDocumentSettingKey($type, 'item_name'), false) && $hideName == 'hide') {
return $hideName;
}

Expand All @@ -1276,7 +1276,7 @@ protected function getHideDescription($type, $hideDescription)
}

// if you use settting translation
if ($hideDescription = setting($this->getSettingKey($type, 'hide_item_description'), false)) {
if ($hideDescription = setting($this->getDocumentSettingKey($type, 'hide_item_description'), false)) {
return $hideDescription;
}

Expand All @@ -1297,7 +1297,7 @@ protected function getHideQuantity($type, $hideQuantity)
}

// if you use settting translation
if ($hideQuantity = setting($this->getSettingKey($type, 'hide_quantity'), false) && $hideQuantity == 'hide') {
if ($hideQuantity = setting($this->getDocumentSettingKey($type, 'hide_quantity'), false) && $hideQuantity == 'hide') {
return $hideQuantity;
}

Expand All @@ -1318,7 +1318,7 @@ protected function getHidePrice($type, $hidePrice)
}

// if you use settting translation
if ($hidePrice = setting($this->getSettingKey($type, 'hide_price'), false) && $hidePrice == 'hide') {
if ($hidePrice = setting($this->getDocumentSettingKey($type, 'hide_price'), false) && $hidePrice == 'hide') {
return $hidePrice;
}

Expand All @@ -1339,7 +1339,7 @@ protected function getHideDiscount($type, $hideDiscount)
}

// if you use settting translation
if ($hideDiscount = setting($this->getSettingKey($type, 'hide_discount'), false)) {
if ($hideDiscount = setting($this->getDocumentSettingKey($type, 'hide_discount'), false)) {
return $hideDiscount;
}

Expand All @@ -1360,7 +1360,7 @@ protected function getHideAmount($type, $hideAmount)
}

// if you use settting translation
if ($hideAmount = setting($this->getSettingKey($type, 'hide_amount'), false)) {
if ($hideAmount = setting($this->getDocumentSettingKey($type, 'hide_amount'), false)) {
return $hideAmount;
}

Expand Down

0 comments on commit ee5822f

Please sign in to comment.