<?php

namespace App\Models;

use App\Enums\OrderStatusEnum;
use App\Enums\OrderType;
use App\Traits\SelfReferenceTraits;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
 * @method static find(int $orderId)
 * @method static where($column, $operator = null, $value = null, $boolean = 'and')
 * @method children()
 *
 * @property HasMany children
 * @property OrderStatusEnum orderStatus
 * @property int|null parent_id
 * @property OrderType orderType
 */
class Order extends BaseAuditable
{
    use SelfReferenceTraits;

    protected $guarded = ['id', 'created_at', '	updated_at'];

    public function supplier(): BelongsTo
    {
        return $this->belongsTo(Supplier::class);
    }

    public function profitCenter(): BelongsTo
    {
        return $this->belongsTo(ProfitCenter::class);
    }

    public function orderNumber(): HasOne
    {
        return $this->hasOne(OrderNumber::class);
    }
}
