<?php
namespace TourOperatorProBlock\block_testimonial_carousel;
use TourOperatorPro\Factory as FactoryAlias;
use TourOperatorPro\Utilities\Utility as UtilityAlias;
use TourOperatorProFrontend\app\helpers\DestinationHelper;
class block_testimonial_carousel_helper{
    public static function get_tour_by_destination_id($testimonial_carousel_id=0){
       $destination_key=DestinationHelper::getDestinationKey();
        $db= FactoryAlias::getDBO();
        $query=$db->getQuery(true);
        $query->select('tour.*')
            ->from(UtilityAlias::getTableName('tour').' AS tour ')
            ->leftJoin(UtilityAlias::getTableName('tourproperty'). ' AS tourproperty ON tourproperty.tour_id = tour.id')
            ->where('tour.published=1')
        ;
            if($testimonial_carousel_id!=0){
                $query->where('type ='.$query->quote($destination_key))
                    ->where('object_id='.(int)$testimonial_carousel_id);
            }
            $query->group('tour.id')
        ;
       $list=$db->setQuery($query)->loadObjectList();
        return $list;
    }
}