<?php

namespace App\Modules\Invoice\Models;

use App\Modules\Tenant\Models\Company;
use App\Modules\CustomerPortal\Models\CustomerPortalAccount;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Customer extends Model
{
    use HasFactory;

    protected $fillable = [
        'company_id',
        'name',
        'email',
        'phone',
        'address',
        'status',
    ];

    /**
     * @return BelongsTo<Company, Customer>
     */
    public function company(): BelongsTo
    {
        return $this->belongsTo(Company::class);
    }

    /**
     * @return HasMany<Invoice>
     */
    public function invoices(): HasMany
    {
        return $this->hasMany(Invoice::class);
    }

    /**
     * @return HasOne<CustomerPortalAccount>
     */
    public function portalAccount(): HasOne
    {
        return $this->hasOne(CustomerPortalAccount::class);
    }
}
