Blame | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** Brands Controller** @property Brand $Brand* @property PaginatorComponent $Paginator*/class BrandsController extends AppController {/*** Components** @var array*/public $components = array('Paginator');/*** index method** @return void*/public function index() {$this->Brand->recursive = 0;$this->set('brands', $this->Paginator->paginate());}/*** view method** @throws NotFoundException* @param string $id* @return void*/public function view($id = null) {if (!$this->Brand->exists($id)) {throw new NotFoundException(__('Invalid brand'));}$options = array('conditions' => array('Brand.' . $this->Brand->primaryKey => $id));$this->set('brand', $this->Brand->find('first', $options));}/*** add method** @return void*/public function add() {if ($this->request->is('post')) {$this->Brand->create();if ($this->Brand->save($this->request->data)) {$this->Session->setFlash(__('The brand has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The brand could not be saved. Please, try again.'));}}}/*** edit method** @throws NotFoundException* @param string $id* @return void*/public function edit($id = null) {if (!$this->Brand->exists($id)) {throw new NotFoundException(__('Invalid brand'));}if ($this->request->is(array('post', 'put'))) {if ($this->Brand->save($this->request->data)) {$this->Session->setFlash(__('The brand has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The brand could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('Brand.' . $this->Brand->primaryKey => $id));$this->request->data = $this->Brand->find('first', $options);}}/*** delete method** @throws NotFoundException* @param string $id* @return void*/public function delete($id = null) {$this->Brand->id = $id;if (!$this->Brand->exists()) {throw new NotFoundException(__('Invalid brand'));}$this->request->onlyAllow('post', 'delete');if ($this->Brand->delete()) {$this->Session->setFlash(__('The brand has been deleted.'));} else {$this->Session->setFlash(__('The brand could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}/*** admin_index method** @return void*/public function admin_index() {$this->Brand->recursive = 0;$this->set('brands', $this->Paginator->paginate());}/*** admin_view method** @throws NotFoundException* @param string $id* @return void*/public function admin_view($id = null) {if (!$this->Brand->exists($id)) {throw new NotFoundException(__('Invalid brand'));}$options = array('conditions' => array('Brand.' . $this->Brand->primaryKey => $id));$this->set('brand', $this->Brand->find('first', $options));}/*** admin_add method** @return void*/public function admin_add() {if ($this->request->is('post')) {$this->Brand->create();if ($this->Brand->save($this->request->data)) {$this->Session->setFlash(__('The brand has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The brand could not be saved. Please, try again.'));}}}/*** admin_edit method** @throws NotFoundException* @param string $id* @return void*/public function admin_edit($id = null) {$this->response->type('json');$this->layout = 'ajax';if (!$this->Brand->exists($id)) {throw new NotFoundException(__('Invalid brand'));}if ($this->request->is(array('post', 'put'))) {if ($this->Brand->save($this->request->data)) {$result = array('success'=>true,'message'=>'The brand has been edited');} else {$result = array('success'=>false,'message'=>'The brand could not be edited. Try again later');}}$this->set(array('result' => $result,'_serialize' => array('result')));$this->render('/Elements/json');}/*** admin_delete method** @throws NotFoundException* @param string $id* @return void*/public function admin_delete($id = null) {$this->Brand->id = $id;if (!$this->Brand->exists()) {throw new NotFoundException(__('Invalid brand'));}$this->request->onlyAllow('post', 'delete');if ($this->Brand->delete()) {$this->Session->setFlash(__('The brand has been deleted.'));} else {$this->Session->setFlash(__('The brand could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}}