<?php
defined('_WPBOOKINGPRO_EXEC') or die;
use WooBooking\CMS\Filesystem\File;
use WooBooking\CMS\Utilities\Utility;
if(!class_exists("WpBookingPro_ReviewModel")) {
    /**
     * Class WpBookingPro_ReviewModel
     */
    class WpBookingPro_ReviewModel extends WoobookingModelForm
    {
        /**
         * @var string
         */
        public $table_name = "review";
        /**
         * @var string
         */
        public $context = "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'];
            $reviewModel = WoobookingModel::getInstance('review');
            $service_id = $data['service_id'];
            $serviceModel = WoobookingModel::getInstance('service');
            $service = $serviceModel->getItem($service_id);
            $created_date = Factory::getDate();
            $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 = $reviewModel->save($data_review);
            return $review;
        }
    }
}