<?php
namespace WpBookingProAdminWooPanel\app\models;
defined('_WPBOOKINGPRO_EXEC') or die;

use Exception;
use WpBookingPro\Factory;
use WpBookingPro\Language\Text;
use WpBookingPro\Mvc\Model\ModelForm;
use WpBookingPro\Filesystem\File as FileAlias;
use WpBookingPro\Mvc\Model\Model;
use WpBookingPro\Form\Form;
use WpBookingPro\Mvc\Model\ModelList;
use WpBookingPro\Registry\Registry;
use WpBookingPro\Utilities\Utility;

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

    public function getItem($id = 0)
    {
        $db = Factory::getDBO();
        $query = $db->getQuery(true);
        $review =  parent::getItem($id); // TODO: Change the autogenerated stub
        $query->clear()
            ->select('service_id')
            ->from($this->getTableName('service_review'))
            ->where('review_id='.(int)$review->id)
        ;
        $review->service_id = $db->setQuery($query)->loadResult();
        $query->clear()
            ->select('user_id')
            ->from($this->getTableName('vendor_review'))
            ->where('review_id='.(int)$review->id)
        ;
        $review->user_id = $db->setQuery($query)->loadResult();
        return $review;
    }

}
