Jump to content

Recommended Posts

Hi, I'm getting this error and I can't seem to figure it out. Can someone help me on this?

 

Notice ( 8) : 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'));
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/237203-cakephp-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.