LdapRecord-Laravel: [Question] Event listener not triggering
Environment:
- LDAP Server Type: ActiveDirectory
- LdapRecord-Laravel Major Version: v3
- PHP Version: 8.1.7
Hi Steve, I’m trying to get the event listener to work. Basically, I wish to fire up an email notification when a user is being imported.
This is the command I use to import a single user which works fine.
php artisan ldap:import ldap --filter "(cn=John Doe)"
I then have this on my EventServiceProvider
file.
/**
* The event listener mappings for the application.
*
*/
protected $listen = [
//...
\LdapRecord\Laravel\Events\Importing::class => [
\App\Ldap\Listeners\ObjectImporting::class
],
// ...
];
This is my listener saved in App\Ldap\Listeners\ObjectImporting.php
.
namespace App\Ldap\Listeners;
use LdapRecord\Laravel\Events\Importing;
use Stackkit\LaravelDatabaseEmails\Email;
class ObjectImporting
{
public function handle(Importing $event)
{
$objectName = $event->getModel()->getName();
Email::compose()
->label('test_ldap')
->recipient('notifications@local')
->subject('Test Ldap')
->view('emails.demo')
->variables([
'name' => $objectName,
])
->send();
}
}
The mail package I am using creates a record on my database for any email that will be sent. However if I issue the command to import, it’s not triggerring the email.
Any ideas?
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- Fix suggested namespace https://github.com/DirectoryTree/LdapRecord-Laravel/issues/545 — committed to DirectoryTree/LdapRecord-Docs by stevebauman a year ago
Awesome, thank you very much @stevebauman you’re a star!