diff --git a/Providers/MMFCustomersGroupsServiceProvider.php b/Providers/MMFCustomersGroupsServiceProvider.php index 93251ad..a1fc118 100644 --- a/Providers/MMFCustomersGroupsServiceProvider.php +++ b/Providers/MMFCustomersGroupsServiceProvider.php @@ -6,8 +6,13 @@ namespace Modules\MMFCustomersGroups\Providers; +use Eventy; +use View; + use Illuminate\Support\ServiceProvider; +use Modules\MMFCustomersGroups\Entities\Mailbox; + class MMFCustomersGroupsServiceProvider extends ServiceProvider { /** * Indicates if loading of the provider is deferred. @@ -75,8 +80,22 @@ class MMFCustomersGroupsServiceProvider extends ServiceProvider { */ public function hooks() { // Add a menu entry to manage the customer groups. - \Eventy::addAction('menu.manage.after_mailboxes', function() { - echo \View::make('mmfcustomersgroups::partials/menu', [])->render(); + Eventy::addAction('menu.manage.after_mailboxes', function() { + echo View::make('mmfcustomersgroups::partials/menu', [])->render(); }); + + // Add a list of customer groups to select from when writing a new conversation. + Eventy::addAction('conversation.create_form.before_subject', function($conversation, $mailbox, $thread) { + // We must fetch a fresh Mailbox instance, + // as the one that has been passed does not have a "groups" relationship. + $mailbox = Mailbox::find($mailbox->id); + $groups = $mailbox->groups; + echo View::make( + 'mmfcustomersgroups::conversations/partials/groups-selection', + [ + 'groups' => $groups, + ], + )->render(); + }, 20, 3); } } diff --git a/Resources/views/conversations/partials/groups-selection.blade.php b/Resources/views/conversations/partials/groups-selection.blade.php new file mode 100644 index 0000000..8ec33d2 --- /dev/null +++ b/Resources/views/conversations/partials/groups-selection.blade.php @@ -0,0 +1,36 @@ + + */ +?> + +@include('partials/flash_messages') + + +