menerapkan generate code system di feature Jenis Fasilitas Kredit
This commit is contained in:
27
app/Http/Library/LpjHelpers.php
Normal file
27
app/Http/Library/LpjHelpers.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Library;
|
||||
|
||||
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
trait LpjHelpers
|
||||
{
|
||||
|
||||
public static function onLastCodeJFK(): string
|
||||
{
|
||||
// max(code)
|
||||
$noUrutAkhir2 = JenisFasilitasKredit::withTrashed()->max('code');
|
||||
|
||||
$noUrutAkhir=sprintf("%06s", 1);
|
||||
$noUrutAwal = 'JFK';
|
||||
$noUrutAkhirString = $noUrutAkhir;
|
||||
if($noUrutAkhir2){
|
||||
$noUrutAkhir = substr($noUrutAkhir2, 3, 6);
|
||||
// $noUrutAwal = substr($noUrutAkhir2, 0, 3);
|
||||
$noUrutAkhirString = sprintf("%06s", abs($noUrutAkhir + 1));
|
||||
}
|
||||
|
||||
return $noUrutAwal . $noUrutAkhirString;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user