I am writing an app that displays housing units (they are listed by users offering them for rent). I am trying to figure out how to define my Unit model in Cakephp. I have three tables: units, complexes and users.
I know that unit $belongsTo 'User', but it also belongs to 'Complex', since every complex can have many units. Can my I write this?
<?php
class Unit extends AppModel {
var $name='Unit';
var $belongsTo=array('User', 'Complex');
} ?>
I should also add that I am not sure how to define my classes for User and Complex, as a User can have many Complexes and a Complex can have many Users. If one hasMany can it also belongTo the thing that it hasMany of? Is this a HABTM? I am very confused (newbie).