ARTICLE AD BOX
I have a model, let's say Item, that makes a call to an external API on creation to synchronize with that service:
class Item extends Model { protected static function booted() { static::creating(function ($item) { API::create(array($item->id)); }); } }That works great, but now I want to also make a call to the API on deletion:
static::deleting(function ($item) { API::delete(array($item->id)); });This works, but won't run when the migration for this model reverses (for example when I run artisan migrate:refresh) because the table is just being dropped without calling deleting .
My question: is there a way to ensure that the deleting method is called during migration reversal (ie from the Migration down method) or am I looking at this problem wrong and there's a much more elegant solution? (as usually seems to be the case with Laravel :P)
