<?php
namespace App\Models;
use CodeIgniter\Model;

class FrontpageModel extends Model{
	
	public function getHeaderData($page_slug) {
		$builder = $this->db->table('header'); // Get builder for a specific table
        $builder->select('*');
        $builder->where('page_slug',$page_slug);
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays
	}
	public function getHeaderDetailsData($id) {
		$builder = $this->db->table('header_details'); // Get builder for a specific table
        $builder->select('*');
        $builder->where('header_id',$id);
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}
	public function getFooterData($page_slug) {
		$builder = $this->db->table('footer'); // Get builder for a specific table
        $builder->select('*');
        $builder->where('page_slug',$page_slug);
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}
	public function getFooterDetailsData($id) {
		$builder = $this->db->table('footer_details'); // Get builder for a specific table
        $builder->select('*');
        $builder->where('footer_id',$id);
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}
	public function getPageData($page_slug) {
		
		$builder = $this->db->table('content'); // Get builder for a specific table
        $builder->select('*');
        $builder->where('page_slug',$page_slug);
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}
	public function getPageDetailsData($id) {
		$builder = $this->db->table('content_details'); // Get builder for a specific table
        $builder->select('*');
        $builder->where('content_id',$id);
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}
	public function getMenuData() {
		$builder = $this->db->table('menu'); // Get builder for a specific table
        $builder->select('*');
        $builder->orderBy('menu_order','ASC');
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}
	
	public function getSubMenuData($parent_menu_slug) {
		$builder = $this->db->table('submenu'); // Get builder for a specific table
        $builder->select('*');
		$builder->where('parent_menu_slug',$parent_menu_slug);
		$builder->orderBy('menu_order','ASC');
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}

	public function checkDuplicatePagenameEdit($id,$name) {
		$builder = $this->db->table('pages'); // Get builder for a specific table
        $builder->select('*');
        $builder->where('page_name', $name);
        $query = $builder->get(); // Runs the query

        return $query->getResult(); // Get results as an array of arrays

	}

}