Merge branch 'feature/list_item' into develop
This commit is contained in:
src
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
6
src/Template/Items/list.ctp
Normal file
6
src/Template/Items/list.ctp
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
<?php
|
||||
foreach ($items as $item) {
|
||||
debug($item);
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user