Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Raise custom event after save method #14

Open
eporsche opened this issue Jul 30, 2019 · 2 comments
Open

Idea: Raise custom event after save method #14

eporsche opened this issue Jul 30, 2019 · 2 comments

Comments

@eporsche
Copy link

eporsche commented Jul 30, 2019

Currently there is no way to register a listener after both the model and its fiillable relations have been saved. I would like to propose something like:
$model->fireHasFillableRelationsEvent('created_with_relations');

after the save method in the HasFillableRelations trait.

protected function fireHasFillableRelationsEvent($event)
    {
        if (! isset($this->dispatchesEvents[$event])) {
            return;
        }
        $result = static::$dispatcher->dispatch(new $this->dispatchesEvents[$event]($this));
        if (! is_null($result)) {
            return $result;
        }
    }
@troelskn
Copy link
Owner

I'm not sure I understand. Wouldn't the saved event cover you?

@eporsche
Copy link
Author

Let's say I have an invoice with multiple line items and I want to raise an event when the invoice and all of its line items have been saved to the database. The saved event on the invoice or on the line items will tell me if they have been saved individually but won't tell me if the complete invoice has been saved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants