Xammie / mailbook

✉️ Laravel Mail Explorer
https://mailbook.dev
MIT License
443 stars 17 forks source link

Define the notifiable using `::to()` #42

Closed Xammie closed 1 year ago

Xammie commented 1 year ago

Thanks to #40 for the idea

Xammie commented 1 year ago

@shanedeakin could you test to see if this solves your problem? You can install it with:

composer require --dev xammie/mailbook dev-add-notifiable
Xammie commented 1 year ago

I'm not 100% sure about the name of the method. Thinking of maybe using to instead. Here are some example ideas of using this method.

Mailbook::to($user)->add(Mailable::class);

Mailbook::to(fn () => User::factory()->create())
    ->add(function () {
        return new Mailable();
    });

Mailbook::to($user, function () {
    Mailbook::add(Mailable::class):

    Mailbook::add(Verification::class):
});

Mailbook::to($user)->group(function () {
    Mailbook::add(Mailable::class):

    Mailbook::add(Verification::class):
});
shanedeakin commented 1 year ago

Yes, this definitely solves the issue for me. I agree that one of the alternate method names provided might be better suited for this.

Is the group() method still just an idea at this point? I just went to test it, but can't see it.

Everything is looking great as far as I can see 👍

Xammie commented 1 year ago

Thanks for testing it.

Yeah the group method is an idea and not (yet) implemented.

Xammie commented 1 year ago

@shanedeakin This has been released in 1.6.0 :)