Retourner Laravel
1) if not exists
public function wallet()
{
return $this->hasOne(Wallet::class)->withDefault([
'name' => 'Wallet Name',
]);
}
2) or force insert when user created please use observer|model boot
protected static function boot()
{
parent::boot();
static::created(static function (self $user) {
$wallet = new Wallet(['name' => 'Wallet Name']);
$user->wallet()->save($wallet);
});
}
Run code snippet
Ramil Huseynov