Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class TournamentsController extends AppController {
- public function index() {
- $this->set('tournaments', $this->Tournament->find('all'));
- }
- public function add() {
- $Version = ClassRegistry::init('Version');
- $this->set('versions', $Version->find('list'));
- if ($this->request->is('post')) {
- $this->request->data['Tournament']['user_id'] = $this->Auth->user('id');
- if ($this->Tournament->save($this->request->data)) {
- $this->Session->setFlash('The tournament has been saved.');
- $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash('Unable to add the tournament.');
- }
- }
- }
- public function edit($id = null) {
- $Version = ClassRegistry::init('Version');
- $this->set('versions', $Version->find('list'));
- $this->Tournament->id = $id;
- if ($this->request->is('get')) {
- $this->request->data = $this->Tournament->read();
- } else {
- if ($this->Tournament->save($this->request->data)) {
- $this->Session->setFlash('The tournament has been updated.');
- $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash('Unable to update the tournament.');
- }
- }
- }
- public function delete($id) {
- if ($this->request->is('get')) {
- throw new MethodNotAllowedException();
- }
- if ($this->Tournament->delete($id)) {
- $this->Session->setFlash('The tournament with id: ' . $id . ' has been deleted.');
- $this->redirect(array('action' => 'index'));
- }
- }
- public function view($id = null) {
- $this->Tournament->id = $id;
- $this->set('tournament', $this->Tournament->read());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment