Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listen to Event : User::creating

I'm doing a new plugin for OctoberCms. I would like to limit the front end registration for some specific domains.

I tried to this :

class Plugin extends PluginBase
{
[......]
    public function boot()
    {
        // Listen for user creation
        Event::listen('eloquent.creating:  October\Rain\Auth\Models\User', function($model) {
        {
            $this->checkDomains($user);
            [.....]
        }
    }
}

But my listener is not working. Do you know what is the Event, I should listen to catch before a new account is created ?

Thanks

like image 785
Pierre-André Vullioud Avatar asked Jan 17 '26 22:01

Pierre-André Vullioud


1 Answers

You can bind to all of the model internal events like this:

User::extend(function($model) {
    $model->bindEvent('model.beforeSave', function() use ($model) {
        // do something
    });
});

You can use before and after for create, update, save, fetch and delete

like image 90
dragontree Avatar answered Jan 19 '26 10:01

dragontree



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!