<?php

namespace App;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    use HasFactory;

    protected $guarded = [];

    public function nominees()
    {
        return $this->hasMany(CustomerNominee::class);
    }

    public function documents()
    {
        return $this->hasMany(CustomerDocument::class);
    }

    public function loans()
    {
        return $this->hasMany(Loan::class);
    }
    public function dpsAccounts()
    {
        return $this->hasMany(DpsAccount::class);
    }

   

    public function admissionFees()
    {
        return $this->hasMany(AdmissionFee::class);
    }

    public function savings()
    {
        return $this->hasMany(Saving::class);
    }

    public function savingsWithdrawals()
    {
        return $this->hasMany(SavingsWithdrawal::class);
    }

    public function totalSavings()
    {
        $total = $this->savings()->sum('amount') - $this->savingsWithdrawals()->sum('amount');
        return $total;
    }



}
