spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

PR Proposal: Allow developer to extend the Campaign model #153

Closed jbraband closed 4 years ago

jbraband commented 4 years ago

Would Spatie be open to a PR that adds a config to allow us to specify a Campaign model subclass to be used by Mailcoach?

I have another model that I'd like to have a HasMany relationship with Campaign and need to add a foreign key to the mailcoach_campaigns table. Figured that extending Campaign would be possible, but I don't see it.

I'm thinking it's be exactly like spatie/laravel-permission does for Permission and Role models (https://github.com/spatie/laravel-permission/blob/47ec7c4c76e675c1a500e46dfb308011d3f3a192/config/permission.php#L16)

jbraband commented 4 years ago

I should also add that I would want the inverse relationship added to the Campaign model to relate back to my class

jbraband commented 4 years ago

This seems a bit bigger of a task than I thought. Mostly because Spatie\Mailcoach\Models\Campaign is referenced all over the package.

Is the correct approach here to add a MailcoachRegistrar class similar to PermissionRegistra (https://github.com/spatie/laravel-permission/blob/47ec7c4c76e675c1a500e46dfb308011d3f3a192/src/PermissionRegistrar.php#L12)?

and then build out a Spatie\Mailcoach\Models\Concerns\Campaign.php interface?

@freekmurze can you think of any roadblocks to this PR?

jbraband commented 4 years ago

I added a placeholder PR for extending the Campaign

https://github.com/spatie/laravel-mailcoach/pull/218

I have the config updated and the MailcoachRegistrar class added. The Campaign interface is stubbed in as well.

freekmurze commented 4 years ago

Closing this now, we'll continue the conversation on that PR at laravel-mailcoach.