Isn't your new user going to need an email address? And you should probably set a random password too.
Look in the network tab of your developer tools in the browser and see what response you are getting. Might be a clue there
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I'm learning laravel livewire, but I'm stuck trying to find a solution. I'd like to have
For this, I've tried modifying the App\Http\Livewire\Student\Create.php :
class Create extends Component
{
public Student $student;
public $first_name,$last_name;
public function mount(Student $student)
{
$this->student = $student;
$this->initListsForFields();
}
public function submit()
{
$this->validate();
$this->student->save();
$newUser = User::create([
'first_name' => $this->first_name,
'last_name' => $this->last_name,
]);
$newUser->roles()->attach(Role::where('title', 'Student')->first());
$this->student->update([
'user_id' => $newUser->id,
'full_name' => $newUser->name
]);
return redirect()->route('admin.students.index');
}
}
But it's not working : it's redirecting me to the same page but with empty fields, and there's no error message. Can someone help me please?
Many thanks in advance,
Please or to participate in this conversation.