oddvalue / laravel-drafts

MIT License
390 stars 18 forks source link

static::updating not firing on Model Update #3

Closed CNSam closed 2 years ago

CNSam commented 2 years ago

Hi there,

When using $model->update() the updating method is not firing thus not creating a new revision of an updated model.

$this->model->update([
            'title' => $this->request->title,
            'content' => $this->request->content,
            'meta_title' => $this->request->meta_title,
            'meta_description' => $this->request->meta_description,
            'slug' => $this->request->slug,
            'parent_id' => $this->request->parent_id,
            'user_id' => auth()->id(),
        ]);

When using the create() method a new record is added with is_published set to 1 and also is_current set to 1 and creates a new uuid for the post and doesn't create any form of relationship to the previous - im not sure if im doing something wrong or if im misunderstanding the docs.

Ultimately, when I update a record, a new revision should be made and by default marked as is_published and is_current and then the previous to be unmarked.

oddvalue commented 2 years ago

Hi @CNSam, that event is part of the core Laravel framework. There are tests in this package that use the update method to create revisions and they're all passing. Would you be able to provide a simple example app that shows the issue in action so I could investigate? Thanks.

CNSam commented 2 years ago

Thanks @oddvalue i'll take another look for sure and see what might be interfering. I have a simple model that doesn't have any other traits assigned that 'should' trigger that updating event. I'll keep digging and let you know if I find anything.

Thanks