<?php

App::uses('Model', 'Model');

/**
 * Application model for Cake.
 *
 * Add your application-wide methods in the class below, your models
 * will inherit them.
 *
 * @package       app.Model
 */

class Division extends AppModel {
			
    public $hasAndBelongsToMany  = array(
			'Depot' => array('className' => 'Depot', 'foreignKey' => 'division_id', 'joinTable'=>'divisions_depots', 'fields'=>array('id','title')), 
			'Region' => array('className' => 'Region', 'foreignKey' => 'division_id', 'fields'=>array('id', 'title'))
		);
		
	 /*---------------------------------------
     * Function: getList
     * Desc: getting the available divisions as list
     * Author: Sridhar
     * Added on: 18 April 2020
     *---------------------------------------*/
    public function getList(){
        $conditions = array();
        return $this->find('list', array( 'fields'=>array('id', 'title'),'conditions'=>$conditions, 'order'=>array('title'=>'asc')));
    }

	
}


