<?php

namespace Modules\Quotation\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Order\Models\Order;
use Modules\Product\Models\Product;
use Modules\User\Enums\AccountStatusEnum;
use Modules\User\Models\User;
use Modules\User\Models\Visitor;

class Quotation extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'count'	,'order_id','user_id'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function user() :BelongsTo
    {
        $user = $this->status == AccountStatusEnum::VISITOR->value ?
            $this->belongsTo(Visitor::class,'user_id')->withTrashed() :
            $this->belongsTo(User::class,'user_id')->withTrashed();
        return $user;
    }
    public function visitor ()
    {
        return $this->belongsTo(Visitor::class,'user_id')->withTrashed();
    }
    public function order()
    {
        return $this->belongsTo(Order::class,'order_id')->withTrashed();
    }

}
