<?php

namespace App\Models;

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

class BillingAccount extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'name',
        'contact_name',
        'primary_parent_user_id',
        'invoice_email',
        'phone',
        'address_line1',
        'address_line2',
        'town',
        'postcode',
        'country',
    ];

    /**
     * The primary parent user linked to this billing account.
     */
    public function primaryParent()
    {
        return $this->belongsTo(User::class, 'primary_parent_user_id');
    }

    /**
     * Students billed under this account.
     */
    public function students()
    {
        return $this->hasMany(StudentProfile::class, 'billing_account_id');
    }
}
