wardrobecms / core-archived

Wardrobe Core Files

Home Page:http://wardrobecms.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

delete/deleting model events are not getting called

newtonianb opened this issue · comments

I'm just not understanding why my delete and deleting events are not getting called while created event is! To create and delete the posts I'm doing it from the base UI.

class Post extends BaseModel implements CommentableModelInterface {

    public static function boot() {
        static::created(function($obj) {
               // this gets called on create
        });
        static::deleting(function($obj) {
         // this does not get called on delete
        });
        static::deleted(function($obj) {
         // this does not get called on delete
        });
    }


I tried seeing if it might be a problem with the chainning

changed

Post::where('id', $id)->where('user_id', $user->id)->delete();

to

$post = Post::where('id', $id)->where('user_id', $user->id);
$post->delete();

The problem is still there. Any idea?

Not sure if this is it but you have deleted instead of delete. Is that the culprit?

I'm looking at the model events available from http://four.laravel.com/docs/eloquent#model-events

Model Events
Eloquent models fire several events, allowing you to hook into various points in the model's lifecycle using the following methods: creating, created, updating, updated, saving, saved, deleting, deleted, restoring, restored.

I'm using this all over my app, it always works pretty straightforward when you delete the model instance it gets triggered, I just don't understand why it's not here.