update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
132
dev/app-bak/helpers.php
Normal file
132
dev/app-bak/helpers.php
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
use App\Services\AboHelper;
|
||||
use App\Domain\DomainContext;
|
||||
use App\Services\DomainService;
|
||||
|
||||
if (! function_exists('make_old_url')) {
|
||||
function make_old_url($path)
|
||||
{
|
||||
return config('app.old_url').$path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('make_old_url')) {
|
||||
function make_old_url($path)
|
||||
{
|
||||
return config('app.old_url').$path;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_file_last_time')) {
|
||||
function get_file_last_time($value)
|
||||
{
|
||||
if (file_exists($value)) {
|
||||
return filemtime($value);
|
||||
}
|
||||
return date("Ymd-is", time());
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_user_attr')) {
|
||||
function get_user_attr($key){
|
||||
if ($user = Auth::user()) {
|
||||
return $user->getSetting($key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('set_user_attr')) {
|
||||
function set_user_attr($key, $value){
|
||||
if ($user = Auth::user()) {
|
||||
return $user->setSetting([$key => $value]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_active_badge')) {
|
||||
function get_active_badge($active, $tooltip = false, $pos = "top")
|
||||
{
|
||||
if($tooltip){
|
||||
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.$tooltip.'"';
|
||||
}
|
||||
return $active ? '<span class="badge badge-pill badge-success" '.$tooltip.'><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger" '.$tooltip.'><i class="fa fa-times"></i></span>';
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('formatNumber')) {
|
||||
function formatNumber($number, $dec=2)
|
||||
{
|
||||
return !$number ? $number : Util::formatNumber($number, $dec);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('reFormatNumber')) {
|
||||
function reFormatNumber($number)
|
||||
{
|
||||
return !$number ? $number : Util::reFormatNumber($number);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('cleanNumberFormat')) {
|
||||
function cleanNumberFormat($number)
|
||||
{
|
||||
return !$number ? $number : Util::cleanNumberFormat($number);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('formatDate')) {
|
||||
function formatDate($date)
|
||||
{
|
||||
return Carbon::parse($date)->format(\Util::formatDateDB());
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('maxStrLength')) {
|
||||
function maxStrLength($str, $lenght = 40)
|
||||
{
|
||||
return !$str ? $str : Util::maxStrLength($str, $lenght); }
|
||||
}
|
||||
|
||||
if (! function_exists('get_abo_type_badge_by_product')) {
|
||||
function get_abo_type_badge_by_product($product){
|
||||
return AboHelper::getAboTypeBadge(AboHelper::getAboShowOn($product));
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_abo_type_badge')) {
|
||||
function get_abo_type_badge($type){
|
||||
return AboHelper::getAboTypeBadge($type);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('cleanIntegerFromString')) {
|
||||
function cleanIntegerFromString($value) {
|
||||
return Util::cleanIntegerFromString($value);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('legal_url')) {
|
||||
/**
|
||||
* Generate URL for legal pages that should always point to shop domain from checkout
|
||||
*/
|
||||
function legal_url($path) {
|
||||
try {
|
||||
$context = app(DomainContext::class);
|
||||
// If we're on checkout domain, redirect legal links to shop domain
|
||||
if ($context->type === 'checkout') {
|
||||
$domainService = app(DomainService::class);
|
||||
return $domainService->buildUrl('main', $path);
|
||||
}
|
||||
|
||||
// For all other domains, use normal URL generation
|
||||
return url($path);
|
||||
} catch (Exception $e) {
|
||||
// Fallback to normal URL if something goes wrong
|
||||
return url($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue