Skip to content

Commit

Permalink
add a delete method to entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Flori committed Oct 8, 2024
1 parent b6d327c commit e60b368
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public function reset($attribute = null)
/**
* Save the entity to EntityManager
*
* @return Entity
* @return $this
* @throws IncompletePrimaryKey
*/
public function save()
Expand All @@ -399,6 +399,20 @@ public function save()
return $this;
}

/**
* Delete the entity
*
* > You might want to implement soft deletes by overriding this method.
*
* @return $this
*/
public function delete()
{
$this->entityManager->delete($this);

return $this;
}

/**
* Returns whether or not the entity exists in database
*
Expand Down

0 comments on commit e60b368

Please sign in to comment.