<?php

namespace Modules\Complaint\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\Option\Models\Option;
use Modules\Order\Models\Order;
use Modules\Product\Models\Product;
use Modules\Rate\Enums\RateStatusEnum;
use Modules\Store\Models\Store;
use Modules\User\Enums\AccountStatusEnum;
use Modules\User\Models\User;
use Modules\User\Models\Visitor;

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

    protected $fillable = [
        'description','reason_id','status','user_id','store_id','order_id'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function account() :BelongsTo
    {
        $user = $this->status == RateStatusEnum::USER->value ?
            $this->belongsTo(User::class,'user_id')->withTrashed() :
            $this->belongsTo(Store::class,'user_id')->withTrashed();
        return $user;
    }
    public function store ()
    {
        return $this->belongsTo(Store::class,'user_id')->withTrashed();
    }
    public function user ()
    {
        return $this->belongsTo(User::class,'user_id')->withTrashed();
    }
    public function order()
    {
        return $this->belongsTo(Order::class,'order_id')->withTrashed();
    }
    public function reason()
    {
        return $this->belongsTo(Option::class,'reason_id')->withTrashed();
    }

}
