2019-03-02 22:44:08 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2019-03-02 22:44:08 +01:00
|
|
|
|
|
|
|
namespace App\Utils;
|
|
|
|
|
2024-01-14 05:05:00 +01:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2023-10-26 04:57:44 +02:00
|
|
|
use App\Models\PaymentTerm;
|
2019-03-02 22:44:08 +01:00
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
class TranslationHelper
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
public static function getIndustries()
|
|
|
|
{
|
2024-06-18 02:24:03 +02:00
|
|
|
|
|
|
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
|
|
|
$industries = app('industries');
|
|
|
|
|
|
|
|
return $industries->each(function ($industry) {
|
2019-03-02 22:44:08 +01:00
|
|
|
$industry->name = ctrans('texts.industry_'.$industry->name);
|
|
|
|
})->sortBy(function ($industry) {
|
|
|
|
return $industry->name;
|
|
|
|
});
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public static function getCountries()
|
|
|
|
{
|
2024-06-18 02:24:03 +02:00
|
|
|
|
|
|
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
2024-07-21 03:30:21 +02:00
|
|
|
// $countries = app('countries');
|
2024-06-18 02:24:03 +02:00
|
|
|
|
2024-07-21 03:30:21 +02:00
|
|
|
return \App\Models\Country::all()->each(function ($country) {
|
2019-03-02 22:44:08 +01:00
|
|
|
$country->name = ctrans('texts.country_'.$country->name);
|
|
|
|
})->sortBy(function ($country) {
|
2022-03-10 06:46:33 +01:00
|
|
|
return $country->iso_3166_2;
|
2019-03-02 22:44:08 +01:00
|
|
|
});
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public static function getPaymentTypes()
|
|
|
|
{
|
2024-06-18 02:24:03 +02:00
|
|
|
|
|
|
|
/** @var \Illuminate\Support\Collection<\App\Models\PaymentType> */
|
2024-07-21 03:30:21 +02:00
|
|
|
// $payment_types = app('payment_types');
|
2024-06-18 02:24:03 +02:00
|
|
|
|
2024-07-21 03:30:21 +02:00
|
|
|
return \App\Models\PaymentType::all()->each(function ($pType) {
|
2019-03-02 22:44:08 +01:00
|
|
|
$pType->name = ctrans('texts.payment_type_'.$pType->name);
|
|
|
|
})->sortBy(function ($pType) {
|
|
|
|
return $pType->name;
|
|
|
|
});
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public static function getLanguages()
|
|
|
|
{
|
2024-06-18 02:24:03 +02:00
|
|
|
|
|
|
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
2024-07-21 03:30:21 +02:00
|
|
|
// $languages = app('languages');
|
2024-06-18 02:24:03 +02:00
|
|
|
|
2024-07-21 03:30:21 +02:00
|
|
|
return \App\Models\Language::all()->each(function ($lang) {
|
2019-03-02 22:44:08 +01:00
|
|
|
$lang->name = ctrans('texts.lang_'.$lang->name);
|
|
|
|
})->sortBy(function ($lang) {
|
|
|
|
return $lang->name;
|
|
|
|
});
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public static function getCurrencies()
|
|
|
|
{
|
2024-06-18 02:24:03 +02:00
|
|
|
|
|
|
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
2024-07-21 03:30:21 +02:00
|
|
|
// $currencies = app('currencies');
|
2024-06-18 02:24:03 +02:00
|
|
|
|
2024-07-21 03:30:21 +02:00
|
|
|
return \App\Models\Currency::all()->each(function ($currency) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_'));
|
2019-03-02 22:44:08 +01:00
|
|
|
})->sortBy(function ($currency) {
|
|
|
|
return $currency->name;
|
|
|
|
});
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public static function getPaymentTerms()
|
|
|
|
{
|
|
|
|
return PaymentTerm::getCompanyTerms()->map(function ($term) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$term['name'] = ctrans('texts.payment_terms_net').' '.$term['num_days'];
|
|
|
|
|
2019-03-02 22:44:08 +01:00
|
|
|
return $term;
|
|
|
|
});
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
|
|
|
}
|