<?php

namespace App\Models;

use App\Blameable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class ProdukTabungan extends Model
{
    use SoftDeletes, Blameable;

    protected $table = 'data_tabungan_produk';

    protected $casts = [
        'id' => 'int',
        'saldo_mengendap' => 'int',
        'admin_bulanan' => 'int',
        'admin_pasif' => 'int',
        'suku_bunga' => 'float',
        'created_by' => 'int',
        'status' => 'int',
        'updated_by' => 'int',
        'deleted_by' => 'int'
    ];

    protected $guarded = [];

    public function ref_akun()
    {
        return $this->belongsTo(Akun::class, 'akun_simpanan_id');
    }

    public function tabungan()
    {
        return $this->hasMany(Tabungan::class, 'produk_id');
    }

    public function akun_simpanan()
    {
        return $this->hasOne(Akun::class, 'kode_akun', 'akun_simpanan_id');
    }

    public function akun_biaya_bunga()
    {
        return $this->hasOne(Akun::class, 'kode_akun', 'akun_biaya_bunga_id');
    }
}
