Closed adam-jones-net closed 3 years ago
we used to create an artisan command (laravel) that ask the user data and create the user with the Sentinel facade.
...
public function handle()
{
$username = $this->ask(_i('Correo electrónico del usuario:'));
$password = $this->secret(_i('Contraseña:'));
$repeatPassword = $this->secret('Repita la contraseña');
$credentials = [
'login' => $username,
'password' => $password,
];
if ($password === $repeatPassword) {
$response = \Sentinel::registerAndActivate($credentials);
$names = $this->ask('Ingrese sus nombres');
$lastNames = $this->ask('Ingrese sus apellidos');
$user = \Sentinel::findById($response->id);
$user->superuser = 1;
$user->save();
Profile::create([
'first_name' => $names,
'last_name' => $lastNames,
'user_id' => $user->id
]);
$this->info('Se ha creado su usuario correctamente');
}
else {
$this->error('Las contraseñas no coinciden');
}
}
...
Thanks @Mxrck that was really useful! :)
I don't think this functionality exists built in but I just wanted to be sure. When I say this I mean without dying sql queries in the CLI ;)