Hi, I'm getting this error and I can't seem to figure it out. Can someone help me on this?
Notice ( : Undefined property: LaborTracker::$Staff [APP/controllers/labor_trackers_controller.php, line 31]
Code
LaborTrackersController::add() - APP/controllers/labor_trackers_controller.php, line 31
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83
Fatal error: Call to a member function find() on a non-object in /var/www/hotel/controllers/labor_trackers_controller.php on line 31
labor_tracker.php
<?php
class LaborTracker extends AppModel {
var $name = 'LaborTracker';
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'Staffs' => array(
'className' => 'Staffs',
'foreignKey' => 'staffs_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Jobs' => array(
'className' => 'Jobs',
'foreignKey' => 'jobs_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
?>
labor_trackers_controllers.php
<?php
class LaborTrackersController extends AppController {
var $name = 'LaborTrackers';
function index() {
$this->LaborTracker->recursive = 0;
$this->set('laborTrackers', $this->paginate());
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid labor tracker', true));
$this->redirect(array('action' => 'index'));
}
$this->set('laborTracker', $this->LaborTracker->read(null, $id));
}
function add() {
if (!empty($this->data)) {
$this->LaborTracker->create();
if ($this->LaborTracker->save($this->data)) {
$this->Session->setFlash(__('The labor tracker has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The labor tracker could not be saved. Please, try again.', true));
}
}
$staffs = $this->LaborTracker->Staff->find('list');
$jobs = $this->LaborTracker->Job->find('list');
$this->set(compact('staffs', 'jobs'));
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid labor tracker', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->LaborTracker->save($this->data)) {
$this->Session->setFlash(__('The labor tracker has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The labor tracker could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->LaborTracker->read(null, $id);
}
$staffs = $this->LaborTracker->Staff->find('list');
$jobs = $this->LaborTracker->Job->find('list');
$this->set(compact('staffs', 'jobs'));
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for labor tracker', true));
$this->redirect(array('action'=>'index'));
}
if ($this->LaborTracker->delete($id)) {
$this->Session->setFlash(__('Labor tracker deleted', true));
$this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('Labor tracker was not deleted', true));
$this->redirect(array('action' => 'index'));
}
function admin_index() {
$this->LaborTracker->recursive = 0;
$this->set('laborTrackers', $this->paginate());
}
function admin_view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid labor tracker', true));
$this->redirect(array('action' => 'index'));
}
$this->set('laborTracker', $this->LaborTracker->read(null, $id));
}
function admin_add() {
if (!empty($this->data)) {
$this->LaborTracker->create();
if ($this->LaborTracker->save($this->data)) {
$this->Session->setFlash(__('The labor tracker has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The labor tracker could not be saved. Please, try again.', true));
}
}
$staffs = $this->LaborTracker->Staff->find('list');
$jobs = $this->LaborTracker->Job->find('list');
$this->set(compact('staffs', 'jobs'));
}
function admin_edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid labor tracker', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->LaborTracker->save($this->data)) {
$this->Session->setFlash(__('The labor tracker has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The labor tracker could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->LaborTracker->read(null, $id);
}
$staffs = $this->LaborTracker->Staff->find('list');
$jobs = $this->LaborTracker->Job->find('list');
$this->set(compact('staffs', 'jobs'));
}
function admin_delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for labor tracker', true));
$this->redirect(array('action'=>'index'));
}
if ($this->LaborTracker->delete($id)) {
$this->Session->setFlash(__('Labor tracker deleted', true));
$this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('Labor tracker was not deleted', true));
$this->redirect(array('action' => 'index'));
}
}
?>