<?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 Order extends AppModel {
	public $belongsTo = array(
		'User' => array('className' => 'User', 'foreignKey' => 'user_id', 'fields' => array('first_name', 'last_name'), 'type'=>'inner'),
		'Customer' => array('className' => 'Customer', 'foreignKey' => 'customer_id', 'fields' => array('id', 'first_name','last_name'), 'type'=>'inner'),
	);
	
	public $hasMany = array(
		'Sale' => array(
            'className' => 'Sale',
            'foreignKey' => 'order_id',
			'dependent' => true
        ),
        'FreeItem' => array(
            'className' => 'FreeItem',
            'foreignKey' => 'order_id',
			'dependent' => true
        ),            
        
    );
	
}