<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Webpatser\Uuid\Uuid;

class QuestionOptions extends Model
{
    use HasFactory, SoftDeletes;

    protected $guarded = ['id'];
    protected $hidden  = ['created_at', 'updated_at'];
    /**
     *  Setup model event hooks
     */
    public static function boot()
    {
        parent::boot();

        self::creating(function ($model) {
            $model->uuid = (string) Uuid::generate(4);
        });
    }

    /**
     * Get the route key for the model.
     *
     * @return string
     */
    public function getRouteKeyName()
    {
        return 'uuid';
    }

    public function questionResultR()
    {
        return $this->hasOne(QuestionResult::class,'question_option_id','id');
    }

    public function questionAnsweredFirstTwo()
    {
        return $this->hasMany(QuestionAnswer::class,'question_option_id','id')->with('userTakeTwo');
//            ->join('users','users.id','question_answers.user_id')->take(2);
    }
}
