<?php

namespace App\Models;

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

class Customer extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'phone',
        'email',
        'address',
        'credit_limit',
        'current_due',
        'currency_id',
        'status',
        'notes',
    ];

    public function currency()
    {
        return $this->belongsTo(Currency::class);
    }

    public function ledgers()
    {
        return $this->hasMany(CustomerLedger::class);
    }

    public function scopeActive($query)
    {
        return $query->where('status', 'active');
    }
}
