Skip to content

Instantly share code, notes, and snippets.

@g33klord
Created Jan 30, 2014
Embed
What would you like to do?
Teacher Model:
<?php
class Teacher extends AppModel {
public $actsAs = array('Containable');
public $hasOne = array('Subject');
Subject Model:
<?php
class Subject extends Model {
public $actsAs = array('Containable');
public $belongsTo= array('Teacher');
Teacher Controller:
<?php
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