feat(support): add role permissions, translator and helper functions
This commit is contained in:
1 parent
32995b714b
commit
2a1d701846
4 files changed
+165
No files matched your search
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Bazaar\Core\Config;
|
||||
|
||||
function basePath(string $relative = ''): string
|
||||
{
|
||||
$root = dirname(__DIR__, 2);
|
||||
return $relative === '' ? $root : $root . '/' . ltrim($relative, '/');
|
||||
}
|
||||
|
||||
function e(?string $value): string
|
||||
{
|
||||
return htmlspecialchars($value ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
|
||||
function config(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return Config::get($key, $default);
|
||||
}
|
||||
|
||||
function slugify(string $value): string
|
||||
{
|
||||
$value = strtolower(trim($value));
|
||||
$value = preg_replace('/[^a-z0-9]+/', '-', $value);
|
||||
return trim((string) $value, '-');
|
||||
}
|
||||
|
||||
function formatMoney(int $cents, string $currency = 'USD'): string
|
||||
{
|
||||
$symbol = match (strtoupper($currency)) {
|
||||
'USD' => '$',
|
||||
'EUR' => 'EUR ',
|
||||
'PLN' => 'PLN ',
|
||||
default => strtoupper($currency) . ' ',
|
||||
};
|
||||
return $symbol . number_format($cents / 100, 2);
|
||||
}
|
||||
Reference in new issue
Block a user