0
votes

My models are "term" and "location". Term depends on Location. Each location has 4 term wih different start_dates and finish_dates.

Can anyone help me with this please?

1

1 Answers

1
votes

In the fields definition:

location_id:
    label: Location
    type: dropdown

term_id:
    label: Term
    type: dropdown
    dependsOn: location

Then, in the controller:

public function getLocationOptions()
{
    // this will return an array of Location names indexed by id
    return Location::pluck('name', 'id);
}

public function getTermOptions()
{
    return Term::where('location_id', $this->location_id)->pluck('name', 'id');
}

For more information: OctoberCMS Documentation