<?php namespace App\Controllers;

class Testimonial extends FrontController{

	public function index(){
		$data['language_code'] = $this->get_requested_lang_code();
		$data['meta_data'] = $this->get_meta_data($data['language_code']);
		$data['testimonial_list']= $this->get_testimonial_list();
		echo $this->view_inner_template('testimonial',$data);
	}

	private function get_meta_data($language_code){
		$data['en']['title'] = "Testimonial";
		$data['en']['description'] = "Testimonial";
		$data['en']['keywords'] = "Testimonial";

		if(isset($data[$language_code])){
			return $data[$language_code];
		}else{
			return $data['en'];
		}
	}
	
	
	private function get_testimonial_list(){
		$builder = $this->cmObj->get_table_builder('testimonial AS mt');
		$builder->join('testimonial_ln AS ln',"mt.testimonial_id=ln.testimonial_id AND ln.language_code='en'","inner");
		$query = $builder->select('mt.testimonial_id,ln.name,ln.city,ln.description')
			->where('mt.status','Active')
			->where('mt.is_deleted','No')
			->orderBy('RAND()')
			->get();
		return $query->getResultArray();
	}

}