<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use App\Traits\ScopedByOwner;

class Supplier extends Model
{
    use ScopedByOwner;
    protected $fillable = [
        'name',
        'contact_name',
        'email',
        'phone',
        'address',
        'user_id',
        'investor_name'
    ];

    /**
     * Get the user (investor) that owns the supplier.
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * Get the capital injections for the supplier.
     */
    public function capitalInjections(): HasMany
    {
        return $this->hasMany(CapitalInjection::class);
    }

    /**
     * Get the products for the supplier.
     */
    public function products(): HasMany
    {
        return $this->hasMany(Product::class);
    }

    /**
     * Get the capital settlements for the supplier.
     */
    public function capitalSettlements(): HasMany
    {
        return $this->hasMany(CapitalSettlement::class);
    }
}
