Skip to content

Commit

Permalink
Perform elasticsearch update on save event
Browse files Browse the repository at this point in the history
  • Loading branch information
Torann committed Mar 26, 2017
1 parent 2aa6e77 commit e593600
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/ModelObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,15 @@
class ModelObserver
{
/**
* Handle the created event for the model.
* Handle the saved event for the model.
*
* @param \Illuminate\Database\Eloquent\Model $model
*/
public function created($model)
public function saved($model)
{
$model->addToHunt();
}

/**
* Handle the updated event for the model.
*
* @param \Illuminate\Database\Eloquent\Model $model
*/
public function updated($model)
{
$this->created($model);
}

/**
* Handle the deleted event for the model.
*
Expand All @@ -41,6 +31,6 @@ public function deleted($model)
*/
public function restored($model)
{
$this->created($model);
$this->saved($model);
}
}

0 comments on commit e593600

Please sign in to comment.