Level 104
The problem is you have an Undefined variable $roles
How does this Blade template get its data?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
what is the problem in this code
<div class="mb-4">
@foreach ( $roles as $role )
<label for="role" :value="__('Register as:')" />
<label>
<input type="radio" name="role" value="{{ $role->id == '2' }}" checked /> Student
</label>
<label class="ml-2">
<input type="radio" name="role" value="{{ $role->id == '3' }}" /> Teacher
</label>
@error('Role')
<div class="text-red-500">
<small>{{ $message }}</small>
</div>
@enderror
@endforeach
</div>,,,
you not defined it in controller
write like this in your controller
$roles = Role::all();
OR
$roles = Role::where('id',$id);
OR
anything . you should define it in controller
Please or to participate in this conversation.