<?php
namespace App\Controller;
class StatusController extends AppController
{
public function index()
{
$status = $this->paginate($this->Status);
$this->set(compact('status'));
}
public function view($id = null)
{
$status = $this->Status->get($id, [
'contain' => []
]);
$this->set('status', $status);
}
public function add()
{
$status = $this->Status->newEntity();
if ($this->request->is('post')) {
$status = $this->Status->patchEntity($status, $this->request->getData());
if ($this->Status->save($status)) {
$this->Flash->success(__('The status has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The status could not be saved. Please, try again.'));
}
$this->set(compact('status'));
}
public function edit($id = null)
{
$status = $this->Status->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$status = $this->Status->patchEntity($status, $this->request->getData());
if ($this->Status->save($status)) {
$this->Flash->success(__('The status has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The status could not be saved. Please, try again.'));
}
$this->set(compact('status'));
}
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$status = $this->Status->get($id);
if ($this->Status->delete($status)) {
$this->Flash->success(__('The status has been deleted.'));
} else {
$this->Flash->error(__('The status could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/15 13:33