feat: custom helper
This commit is contained in:
parent
56edf0c680
commit
4880d88ffb
12
app/Helpers/date_helpers.php
Normal file
12
app/Helpers/date_helpers.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
if (! function_exists('formatDateIndo')) {
|
||||||
|
function formatDateIndo($date, $format = 'l, d F Y', $locale = 'id')
|
||||||
|
{
|
||||||
|
Carbon::setLocale('id');
|
||||||
|
|
||||||
|
return Carbon::parse($date)->translatedFormat('D, d M Y');
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Helpers/encryption_helpers.php
Normal file
21
app/Helpers/encryption_helpers.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Hashids\Hashids;
|
||||||
|
|
||||||
|
if (! function_exists('encryptId')) {
|
||||||
|
function encryptId($id)
|
||||||
|
{
|
||||||
|
$hashids = new Hashids('PiscokGodog');
|
||||||
|
|
||||||
|
return $hashids->encode([$id, 54715]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('decryptId')) {
|
||||||
|
function decryptId($hashId)
|
||||||
|
{
|
||||||
|
$hashids = new Hashids('PiscokGodog');
|
||||||
|
|
||||||
|
return $hashids->decode($hashId)[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
0
app/Helpers/setting_helpers.php
Normal file
0
app/Helpers/setting_helpers.php
Normal file
21
app/Helpers/string_helpers.php
Normal file
21
app/Helpers/string_helpers.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (! function_exists('removeRupiahFormatting')) {
|
||||||
|
function removeRupiahFormatting($value)
|
||||||
|
{
|
||||||
|
$convertedValue = str_replace(['Rp', '.', ' '], '', $value);
|
||||||
|
|
||||||
|
$convertedValue = str_replace(',', '.', $convertedValue);
|
||||||
|
|
||||||
|
return $convertedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('formatToRupiah')) {
|
||||||
|
function formatToRupiah($value)
|
||||||
|
{
|
||||||
|
$valueFormatted = 'Rp'.number_format($value, 2, ',', '.');
|
||||||
|
|
||||||
|
return $valueFormatted;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user