delete() public method

Deletes record matching the ID
public delete ( $id = null )
Example #1
0
 /**
  * Deletes record matching the ID (implementation of soft delete)
  * 
  * @param int $id
  * 
  * @return this
  */
 function delete($id = null)
 {
     if ($this->policy_soft_delete) {
         if (!is_null($id)) {
             $this->load($id);
         }
         if (!$this->loaded()) {
             throw $this->exception('Unable to determine which record to delete');
         }
         $this->set('deleted', true)->saveAndUnload();
         return $this;
     } else {
         return parent::delete($id);
     }
 }