<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Partner_model — clients & partners (homepage slider + Partners page).
 */
#[\AllowDynamicProperties]
class Partner_model extends MY_Model {

	protected $table = 'partners';
	protected $order_by = 'sort_order ASC, name ASC';

	/** All active partners. */
	public function active()
	{
		return $this->get_all(array('is_active' => 1));
	}

	/** Featured partners for the moving homepage logo slider. */
	public function featured()
	{
		return $this->get_all(array('is_active' => 1, 'is_featured' => 1));
	}

	/** Active partners grouped by category for the Partners page. */
	public function by_category()
	{
		$rows = $this->active();
		$out  = array();
		foreach ($rows as $r)
		{
			$cat = $r['category'] ?: 'partner';
			$out[$cat][] = $r;
		}
		return $out;
	}
}
