Skip to content

Instantly share code, notes, and snippets.

Created Jan 30, 2014
What would you like to do?
Teacher Model:
class Teacher extends AppModel {
public $actsAs = array('Containable');
public $hasOne = array('Subject');
Subject Model:
class Subject extends Model {
public $actsAs = array('Containable');
public $belongsTo= array('Teacher');
Teacher Controller:
class TeachersController extends AppController {
var $components=array('Email','Session');
var $helpers=array('Html','Form','Session');
var $uses = array('Teacher','Subject');
public function index() {
$results = $this->Teacher->find('all',array('contain'=>array('Subject'))); //Should return Teacher + Subject as well
$this->set('results', $results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment