Untitled
unknown
php
a year ago
1.1 kB
9
Indexable
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Trs_Tanterima_Ku;
use Illuminate\Support\Str;
class TrsTanTerima extends Model
{
protected $table = 'trs_tanterima';
protected $primaryKey = 'id_tanterima';
protected $keyType = 'string';
public $incrementing = false;
protected $fillable = [
'vendorid',
'tanggal_terima',
'top',
'curr',
'pembayaranid',
'deptid',
'note_kasir',
'status',
// Tambahkan field lainnya sesuai database
];
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
if (empty($model->id_tanterima)) {
$uuid32 = str_replace('-', '', Str::uuid()->toString());
$uuid10 = substr($uuid32, 0, 10);
$model->id_tanterima = $uuid10;
}
});
}
// Relasi dengan TanterimaKu
public function kuitansi()
{
return $this->hasMany(TrsTanterimaKu::class, 'id_tanterima', 'id_tanterima');
}
}
Editor is loading...
Leave a Comment