File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,7 @@ private function create(?string $username = null, ?string $email = null): void
257
257
{
258
258
$ data = [];
259
259
260
+ // If you don't use `username`, remove the validation rules for it.
260
261
if ($ username === null && isset ($ this ->validationRules ['username ' ])) {
261
262
$ username = $ this ->prompt ('Username ' , null , $ this ->validationRules ['username ' ]['rules ' ]);
262
263
}
@@ -301,7 +302,12 @@ private function create(?string $username = null, ?string $email = null): void
301
302
$ userModel = model (UserModel::class);
302
303
303
304
$ user = new UserEntity ($ data );
304
- $ userModel ->save ($ user );
305
+
306
+ if ($ username === null ) {
307
+ $ userModel ->allowEmptyInserts ()->save ($ user );
308
+ } else {
309
+ $ userModel ->save ($ user );
310
+ }
305
311
306
312
$ this ->write ('User " ' . $ username . '" created ' , 'green ' );
307
313
}
You can’t perform that action at this time.
0 commit comments