Frozennode\Administrator\AdminController::updateOptions PHP Method

updateOptions() public method

Gets a list of related items given constraints.
public updateOptions ( string $modelName ) : array
$modelName string
return array of objects [{id: string} ... {1: 'name'}, ...]
    public function updateOptions($modelName)
    {
        $fieldFactory = app('admin_field_factory');
        $response = array();
        //iterate over the supplied constrained fields
        foreach ($this->request->input('fields', array()) as $field) {
            //get the constraints, the search term, and the currently-selected items
            $constraints = array_get($field, 'constraints', array());
            $term = array_get($field, 'term', array());
            $type = array_get($field, 'type', false);
            $fieldName = array_get($field, 'field', false);
            $selectedItems = array_get($field, 'selectedItems', false);
            $response[$fieldName] = $fieldFactory->updateRelationshipOptions($fieldName, $type, $constraints, $selectedItems, $term);
        }
        return response()->json($response);
    }