1class User extends Eloquent
2{
3 public function photos()
4 {
5 return $this->has_many('Photo');
6 }
7
8 // this is a recommended way to declare event handlers
9 public static function boot() {
10 parent::boot();
11
12 static::deleting(function($user) { // before delete() method call this
13 $user->photos()->delete();
14 // do the rest of the cleanup...
15 });
16 }
17}
18