<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Transaction extends Model
{
use HasFactory;
protected $table = 'xyz_incoming_cashes';
// protected $fillable = ['rekening', 'sumber', 'date', 'amount', 'description', 'status'];
protected $guarded = ['id'];
// Database's Relations
// none
// Business Logic
public static function penyebut($nilai)
{
$nilai = abs($nilai);
$huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
$temp = "";
if ($nilai < 12) {
$temp = " " . $huruf[$nilai];
} else if ($nilai < 20) {
$temp = self::penyebut($nilai - 10) . " belas";
} else if ($nilai < 100) {
$temp = self::penyebut($nilai / 10) . " puluh" . self::penyebut($nilai % 10);
} else if ($nilai < 200) {
$temp = " seratus" . self::penyebut($nilai - 100);
} else if ($nilai < 1000) {
$temp = self::penyebut($nilai / 100) . " ratus" . self::penyebut($nilai % 100);
} else if ($nilai < 2000) {
$temp = " seribu" . self::penyebut($nilai - 1000);
} else if ($nilai < 1000000) {
$temp = self::penyebut($nilai / 1000) . " ribu" . self::penyebut($nilai % 1000);
} else if ($nilai < 1000000000) {
$temp = self::penyebut($nilai / 1000000) . " juta" . self::penyebut($nilai % 1000000);
} else if ($nilai < 1000000000000) {
$temp = self::penyebut($nilai / 1000000000) . " milyar" . self::penyebut(fmod($nilai, 1000000000));
} else if ($nilai < 1000000000000000) {
$temp = self::penyebut($nilai / 1000000000000) . " trilyun" . self::penyebut(fmod($nilai, 1000000000000));
}
return $temp;
}
public static function terbilang($nilai)
{
if ($nilai < 0) {
$hasil = "minus " . trim(self::penyebut($nilai));
} else {
$hasil = trim(self::penyebut($nilai));
}
return $hasil;
}
public static function tanggalSekarang()
{
$tanggalSekarang = date("d"); // Mendapatkan tanggal (hari) sekarang
$bulanSekarang = date("M"); // Mendapatkan bulan sekarang dalam format singkat (contoh: Sep)
$tahunSekarang = date("Y"); // Mendapatkan tahun sekarang
// Ubah bulan singkat menjadi format tiga huruf (contoh: Jan, Feb, Mar, dll.)
$bulanSingkat = date("M", strtotime("2000-$bulanSekarang-01"));
return "$tanggalSekarang $bulanSingkat $tahunSekarang";
}
}
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]