<?php

namespace App\Modules\Frontend\Controllers;

use CodeIgniter\Controller;
use App\Modules\Frontend\Models\TourModel;
use App\Modules\Admin\Models\BlogModel; // BlogModel is in Admin namespace (as per your setup)

class HomeController extends Controller
{
    public function index()
    {
        $tourModel = new TourModel();
        $blogModel = new BlogModel();

        // Fetch active tours
        $tours = $tourModel->where('is_active', 1)
                           ->orderBy('created_at', 'DESC')
                           ->limit(3)
                           ->findAll();

        // Fetch published blog posts — using 'status' column (NOT 'is_published')
        $blogPosts = $blogModel->where('status', 'published')
                               ->orderBy('created_at', 'DESC')
                               ->limit(3)
                               ->findAll();

        $data = [
            'tours' => $tours,
            'blogPosts' => $blogPosts,
            'meta_title' => 'Mount Kenya Treks & Safaris – Guided Climbing Expeditions',
            'meta_desc' => 'Expert-guided Mount Kenya treks: Naro Moru, Sirimon & Chogoria routes. All-inclusive, safe, and unforgettable.'
        ];

        return view('App\Modules\Frontend\Views\home', $data);
    }
}