<?php

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

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

    protected $fillable = [
        'rate','comment','comment','user_id','user_status','product_id'
    ];


    public function getDateAttribute()
    {
        $date = date('d',strtotime($this->created_at));
        $date .= ' '.__('web.monthes.'.date('m',strtotime($this->created_at)));
        $date .= ' '.date('Y',strtotime($this->created_at));
        return $date;
    }
    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function user() :BelongsTo
    {
        return $this->belongsTo(User::class,'user_id')->withTrashed();
    }
    public function visitor ()
    {
        return $this->belongsTo(Visitor::class,'user_id')->withTrashed();
    }
    public function product()
    {
        return $this->belongsTo(Product::class,'product_id')->withTrashed();
    }

}
