<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class UserIdentityQuestionAnswer extends BaseModel
{
    use HasFactory;
    protected $fillable=['question', 'answer' ,'user_id'];

    public function insertData($inputData){

        $result = [];
            $insertData = [];

            if(!empty($inputData)){
                foreach ($inputData['data'] as $data){
                    $insertData[] = [
                        'user_id' => $inputData['user_id'],
                        'question' => $data['question'],
                        'answer' => $data['answer']['name'],
                        'created_at' => $this->getSystemCurrentTimeStamp(),
                    ];
                }
            }

            if(!empty($insertData)) {
                $result = self::insert($insertData);
            }
        return $result;
    }
    public function  getUserIdentityQuestionAnswer($user_id)
    {
        $questionAnswer=[];
        $questionAnswer = self::where('user_id',$user_id)->get();
        return $questionAnswer;
    }
}
