Merge pull request #995 from cviebrock/eloquent-delete-doc

Deleting Eloquent models
This commit is contained in:
Dayle Rees
2012-07-27 03:59:15 -07:00

View File

@@ -15,6 +15,7 @@
- [Setter & Getter Methods](#getter-and-setter-methods) - [Setter & Getter Methods](#getter-and-setter-methods)
- [Mass-Assignment](#mass-assignment) - [Mass-Assignment](#mass-assignment)
- [Converting Models To Arrays](#to-array) - [Converting Models To Arrays](#to-array)
- [Deleting Models](#delete)
<a name="the-basics"></a> <a name="the-basics"></a>
## The Basics ## The Basics
@@ -537,3 +538,12 @@ Sometimes you may wish to limit the attributes that are included in your model's
public static $hidden = array('password'); public static $hidden = array('password');
} }
<a name="delete"></a>
## Deleting Models
Because Eloquent inherits all the features and methods of Fluent queries, deleting models is a snap:
$author->delete();
Note, however, than this won't delete any related models (e.g. all the author's Book models will still exist), unless you have set up [foreign keys](/docs/database/schema#foreign-keys) and cascading deletes.