1
0

Merge branch 'feature/list_item' into develop

This commit is contained in:
Korlan Colas
2016-12-01 12:52:08 -08:00
3 changed files with 36 additions and 4 deletions
src
Controller
Model
Template

@ -18,10 +18,12 @@ class ItemsController extends AppController
*/
public function index()
{
$this->paginate = [
'contain' => ['Categories']
];
$items = $this->paginate($this->Items);
/* $this->paginate = [
'contain' => ['Categories'],
'order' => ['Items.shot' => 'desc']
];*/
//$items = $this->paginate($this->Items->find()->where(['id' => 1])->toArray());
$items = $this->paginate($this->Items->find()->order(['hot' => 'DESC']));
$this->set(compact('items'));
$this->set('_serialize', ['items']);
@ -113,4 +115,20 @@ class ItemsController extends AppController
return $this->redirect(['action' => 'index']);
}
/**
* List method
*
* @param string|null $id Item id.
* @return \Cake\Network\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function list($category_id = null){
$items = $this->Items->find('category', [
'category_id' => $category_id
]);
$this->set(compact('items'));
}
}

@ -96,4 +96,12 @@ class ItemsTable extends Table
return $rules;
}
public function findCategory(Query $query, array $options)
{
$query = $this->find()->where(['category_id =' => $options['category_id']]);
return $query;
}
}

@ -0,0 +1,6 @@
<?php
foreach ($items as $item) {
debug($item);
}
?>