TypeSuivisController.php 3.35 KB
<?php
namespace App\Controller;

use App\Controller\AppController;

/**
 * TypeSuivis Controller
 *
 * @property \App\Model\Table\TypeSuivisTable $TypeSuivis
 */
class TypeSuivisController extends AppController
{

    /**
     * Index method
     *
     * @return \Cake\Network\Response|null
     */
    public function index()
    {
        $typeSuivis = $this->paginate($this->TypeSuivis);

        $this->set(compact('typeSuivis'));
        $this->set('_serialize', ['typeSuivis']);
    }

    /**
     * View method
     *
     * @param string|null $id Type Suivi id.
     * @return \Cake\Network\Response|null
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
     */
    public function view($id = null)
    {
        $typeSuivi = $this->TypeSuivis->get($id, [
            'contain' => []
        ]);

        $this->set('typeSuivi', $typeSuivi);
        $this->set('_serialize', ['typeSuivi']);
    }

    /**
     * Add method
     *
     * @return \Cake\Network\Response|void Redirects on successful add, renders view otherwise.
     */
    public function add()
    {
        $typeSuivi = $this->TypeSuivis->newEntity();
        if ($this->request->is('post')) {
            $typeSuivi = $this->TypeSuivis->patchEntity($typeSuivi, $this->request->data);
            if ($this->TypeSuivis->save($typeSuivi)) {
                $this->Flash->success(__('The type suivi has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The type suivi could not be saved. Please, try again.'));
            }
        }
        $this->set(compact('typeSuivi'));
        $this->set('_serialize', ['typeSuivi']);
    }

    /**
     * Edit method
     *
     * @param string|null $id Type Suivi id.
     * @return \Cake\Network\Response|void Redirects on successful edit, renders view otherwise.
     * @throws \Cake\Network\Exception\NotFoundException When record not found.
     */
    public function edit($id = null)
    {
        $typeSuivi = $this->TypeSuivis->get($id, [
            'contain' => []
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $typeSuivi = $this->TypeSuivis->patchEntity($typeSuivi, $this->request->data);
            if ($this->TypeSuivis->save($typeSuivi)) {
                $this->Flash->success(__('The type suivi has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The type suivi could not be saved. Please, try again.'));
            }
        }
        $this->set(compact('typeSuivi'));
        $this->set('_serialize', ['typeSuivi']);
    }

    /**
     * Delete method
     *
     * @param string|null $id Type Suivi id.
     * @return \Cake\Network\Response|null Redirects to index.
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
     */
    public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);
        $typeSuivi = $this->TypeSuivis->get($id);
        if ($this->TypeSuivis->delete($typeSuivi)) {
            $this->Flash->success(__('The type suivi has been deleted.'));
        } else {
            $this->Flash->error(__('The type suivi could not be deleted. Please, try again.'));
        }
        return $this->redirect(['action' => 'index']);
    }
}