Slide 42
Slide 42 text
BETTER BASE METHODS
public
function
delete($id
=
null)
{
if
(!empty($this-‐>data['Category']['id']))
{
if
($this-‐>Category-‐>delete($this-‐>data['Category']['id']))
{
$this-‐>Session-‐>setFlash(__d('admin',
'Category
deleted',
true),
'flash/success');
$this-‐>redirect(array('action'
=>
'index'));
}
$this-‐>Session-‐>setFlash(__d('admin',
'Category
was
not
deleted',
true),
'flash/error');
$id
=
$this-‐>data['Category']['id'];
}
$this-‐>data
=
$this-‐>Category-‐>find('delete',
compact('id'));
if
(!$this-‐>data)
{
$this-‐>Session-‐>setFlash(__d('admin',
'Category
unspecified',
true),
'flash/error');
$this-‐>redirect(array('action'
=>
'index'));
}
}