Skip to content

Instantly share code, notes, and snippets.

@swthate
Last active August 29, 2015 14:00
Show Gist options
  • Save swthate/11182871 to your computer and use it in GitHub Desktop.
Save swthate/11182871 to your computer and use it in GitHub Desktop.
Dashboard
<?php
// app/Model/Dashboard.php
App::uses('AppModel', 'Model');
class Dashboard extends AppModel
{
var $useTable = false;
}
<?php
// app/Controller/DashboardsController.php
App::uses('AppController', 'Controller');
class DashboardsController extends AppController
{
public function index()
{
$this->loadModel('Job');
/*
$this->set('job', $this->Job->find('all', array(
'contain' => 'Client', 'order'=> array(
'Job.id' => 'desc'))));
*/
$this->set('job', $this->Job->find('all', array(
'contain' => 'Client',
'limit' => 5,
'order' => array('Job.id' => 'desc'))));
$this->loadModel('User');
$this->set('authUser', $this->Auth->user());
}
}
array(
'Job' => array(
'client_id' => '2',
'id' => '17',
'datein' => '2014-03-05',
'description' => 'A custom widget built by composition of Autocomplete and Button. You can either type something into the field to get filtered suggestions based on your input, or use the button to get the full list of selections.',
'title' => 'Autocomplete '
)
)
<!-- app/View/Dashboards/index.ctp -->
<h1>Dashboard</h1>
<h2>Welcome</h2>
<?php foreach($jobs as $job): ?>
<p><?php echo $job['Job']['title']; ?><br>
<?php echo $job['Job']['id']; ?><br>
<?php echo $job['Job']['datein']; ?></p>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment