Skip to content

Where to dispatch jobs/send events #11

Closed
@josh-taylor

Description

@josh-taylor

My normal approach for dispatching jobs/sending events would be in the controller action, for example here where we would send an email that a model has been updated:

public function update(Model $model, Request $request) {
    $model->update($request->all());

    dispatch(new SendModelUpdatedEmail($model));

    // ...
}

What would be the recommended approach when extending from the EloquentController to achieve something similar?

My initial thoughts would be to:

  1. Override the update() method on the controller
    • Would have to duplicate the code used in the parent class.
  2. Using Eloquents updated event
    • For me, this logic shouldn't be handled in the Model.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions