<?php
namespace WpBookingEventFrontend\app\models;
defined('_WPBOOKINGEVENT_EXEC') or die;

use WpBookingEvent\Factory;
use WpBookingEvent\Mvc\Model\Model;
use WpBookingEvent\Mvc\Model\ModelForm;
use WpBookingEvent\Form\Form;
use WpBookingEvent\Mvc\Model\ModelList;
use WpBookingEvent\Registry\Registry;
use WpBookingEventAdmin\app\helpers\AdminHelper;

class ReviewModel extends ModelForm
{
    /**
     * @var string
     */
    public $context = "review";
    /**
     * @var string
     */
    public $table_name = "review";

    /**
     * @param array $data
     * @return array|bool|object
     * @throws Exception
     */

    /**
     * @return array
     */
    public function getHeader()
    {
        return array();
    }
    public function add_review($data=array())
    {
       $full_name=$data['full_name'];
       $email=$data['email'];
       $note=$data['note'];
       $rating_service=$data['rating_service'];
       $rating_staff=$data['rating_staff'];
       $rating_ambience=$data['rating_ambience'];
       $service_id = $data['service_id'];
       $serviceModel = Model::getInstance('service');
       $service = $serviceModel->getItem($service_id);
       $created_date = Factory::getDate();
       $review_model= Model::getInstance('review');
       $data_review =[
           "name" => $full_name,
           "comment" => $note,
           "email" => $email,
           "service_id"=>$service_id,
           "rating_service"=>$rating_service,
           "rating_ambience"=>$rating_ambience,
           "rating_staff"=>$rating_staff,
           "created_date"=>$created_date->toSql()
       ];
       $review=$review_model->save($data_review);
       return $review;


    }
    public function add_review_event($data=array())
    {
       $full_name=$data['full_name'];
       $email=$data['email'];
       $note=$data['note'];
       $rating_service=$data['rating_service'];
       $rating_staff=$data['rating_staff'];
       $rating_ambience=$data['rating_ambience'];
       $event_id = $data['event_id'];
       $eventModel = Model::getInstance('event');
       $event = $eventModel->getItem($event_id);
       $created_date = Factory::getDate();
       $review_model= Model::getInstance('review');
       $data_review =[
           "name" => $full_name,
           "comment" => $note,
           "email" => $email,
           "event_id"=>$event_id,
           "rating_service"=>$rating_service,
           "rating_ambience"=>$rating_ambience,
           "rating_staff"=>$rating_staff,
           "created_date"=>$created_date->toSql()
       ];
       $review=$review_model->save($data_review);
       return $review;


    }

}
