I'm making a laravel project using jQuery. And I'd like to create a multiple-selectable dropdown items based on the value from previous field. To be precise, I'd like to create a self-registration form, where
class AcademicFormation extends Model
{
protected $fillable = ['name'];
}
class AcademicSubject extends Model
{
protected $fillable = ['name', 'is_elective', 'is_optional'];
public function academic_formations()
{
return $this->belongsToMany(AcademicFormation::class);
}
}
class AcademicRegistration extends Model
{
protected $fillable = [
'academic_session_id',
'academic_formation_id',
];
public function academic_options()
{
return $this->belongsToMany(AcademicSubject::class);
}
}
class AcademicRegistrationController extends Controller
{
public function create()
{
$academic_sessions = AcademicSession::where('published',1)->get()->pluck('name', 'id');
$academic_formations = AcademicFormation::pluck('name', 'id');
$academic_options = AcademicSubject::where('is_optional', 1)->get()->pluck('name', 'id');
return view('app.academicRegistrations.create', compact('academic_sessions', 'academic_formations', 'academic_options');
}
}
But I don't know how to make a filter inside the create blade, so that when the user select their AcademicFormation, the dropdown of AcademicOption will show only the AcademicSubject which belongs to that specific AcademicFormation.
Can anyone please help, or tell me the keywords/where should I search for tutorials?
Many thanks in advance for any response and help.