<?php

namespace App\Models;

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

class Company extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'company_name',
        'registration_number',
        'vat_number',
        'contact_name',
        'contact_phone',
        'contact_email',
        'billing_address',
        'delivery_address',
        'city',
        'province',
        'postal_code',
        'country',
        'payment_terms_approved',
        'credit_limit',
        'is_verified',
    ];

    protected $casts = [
        'payment_terms_approved' => 'boolean',
        'is_verified' => 'boolean',
        'credit_limit' => 'decimal:2',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function cartItems()
    {
        return $this->hasMany(CartItem::class);
    }

    public function orders()
    {
        return $this->hasMany(Order::class);
    }
}
