Skip to content

Commit 5182d1a

Browse files
committed
chore: rename _helpers to Helpers
1 parent 0a5248c commit 5182d1a

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

app/Helpers/Helpers.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
namespace App\Helpers;
4+
5+
use Carbon\Carbon;
6+
use Illuminate\Support\Str;
7+
8+
class Helper
9+
{
10+
public static function convertToRupiah($price)
11+
{
12+
$price_rupiah = "Rp. " . number_format($price, 2, ',', '.');
13+
return $price_rupiah;
14+
}
15+
16+
public static function thisMonth()
17+
{
18+
return Carbon::parse(Carbon::now())->format('m');
19+
}
20+
21+
public static function thisYear()
22+
{
23+
return Carbon::parse(Carbon::now())->format('Y');
24+
}
25+
26+
public static function dateDayFormat($date)
27+
{
28+
return Carbon::parse($date)->isoFormat('dddd, D MMM YYYY');
29+
}
30+
31+
public static function dateFormat($date)
32+
{
33+
return Carbon::parse($date)->isoFormat('D MMM YYYY');
34+
}
35+
36+
public static function dateFormatTime($date)
37+
{
38+
return Carbon::parse($date)->isoFormat('D MMM YYYY H:m:s');
39+
}
40+
41+
public static function dateFormatTimeNoYear($date)
42+
{
43+
return Carbon::parse($date)->isoFormat('D MMM, hh:mm a');
44+
}
45+
46+
public static function getDateDifference($check_in, $check_out)
47+
{
48+
$check_in = strtotime($check_in);
49+
$check_out = strtotime($check_out);
50+
$date_difference = $check_out - $check_in;
51+
$date_difference = round($date_difference / (60 * 60 * 24));
52+
return $date_difference;
53+
}
54+
55+
public static function plural($value, $count)
56+
{
57+
return Str::plural($value, $count);
58+
}
59+
60+
public static function getColorByDay($day)
61+
{
62+
$color = '';
63+
if ($day == 1) {
64+
$color = 'bg-danger';
65+
} else if ($day > 1 && $day < 4) {
66+
$color = 'bg-warning';
67+
} else {
68+
$color = 'bg-success';
69+
}
70+
return $color;
71+
}
72+
73+
public static function getTotalPayment($day, $price)
74+
{
75+
return $day * $price;
76+
}
77+
}

0 commit comments

Comments
 (0)