<?php
namespace App\Models;
use App\Models\Concerns\NormalizesPhoneNumbers;
use App\Models\Scopes\ParentBranchScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Guarantor extends Model
{
    use NormalizesPhoneNumbers;
    protected $fillable = ['customer_id','full_name','nin','phone','address','occupation','relationship','signed_guarantee_path','status','created_by'];
    protected static function booted(): void { static::addGlobalScope(new ParentBranchScope('customers', 'customer_id')); }
    public function customer(): BelongsTo { return $this->belongsTo(Customer::class); }
    public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); }
    public function loans(): HasMany { return $this->hasMany(Loan::class); }
}
