I am trying to insert some logic when the 'creating' event is fired in the User model of a Laravel/Voyager application, here's my code:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends \TCG\Voyager\Models\User
{
use Notifiable;
public static function boot()
{
parent::boot();
// over-ride the creating event
static::creating(function($user)
{
$user->created_by = auth()->user() ? auth()->user()->id : null;
});
// over-ride the updating event
static::updating(function($user)
{
$user->updated_by = auth()->user() ? auth()->user()->id : null;
});
}
}
But it looks like the 'creating' event is never called, while the 'boot' method is called. Anyone has got any idea why ? Thanks in advance!