classes/Controllers/Base.php
public function formatAutocompleteResponse($results)
    {
        $output = [];
        foreach ($results as $row) {

            // Only keep the id and title fields
            $item = new stdClass;
            $item->id = $row->getKey();
            $item->title = $row->getAdminTitleAttribute();

            // Add properties for the columns mentioned in the list view within the
            // 'columns' property of this row in the response.  Use the same logic
            // found in Decoy::renderListColumn();
            $item->columns = [];
            foreach ($this->columns() as $column) {
                if (method_exists($row, $column)) {
                    $item->columns[$column] = call_user_func([$row, $column]);
                } elseif (isset($row->$column)) {
                    if (is_a($row->$column, 'Carbon\Carbon')) {
                        $item->columns[$column] = $row->$column->format(FORMAT_DATE);
                    } else {
                        $item->columns[$column] = $row->$column;
                    }
                } else {
                    $item->columns[$column] = null;
                }
            }

            // Add the item to the output
            $output[] = $item;
        }

        return $output;
    }
public function formatAutocompleteResponse($results)
    {
        $output = [];
        foreach ($results as $row) {

            // Only keep the id and title fields
            $item = new stdClass;
            $item->id = $row->getKey();
            $item->title = $row->getAdminTitleAttribute();

            // Add properties for the columns mentioned in the list view within the
            // 'columns' property of this row in the response.  Use the same logic
            // found in Decoy::renderListColumn();
            $item->columns = [];
            foreach ($this->columns() as $column) {
                if (method_exists($row, $column)) {
                    $item->columns[$column] = call_user_func([$row, $column]);
                } elseif (isset($row->$column)) {
                    if (is_a($row->$column, 'Carbon\Carbon')) {
                        $item->columns[$column] = $row->$column->format(FORMAT_DATE);
                    } else {
                        $item->columns[$column] = $row->$column;
                    }
                } else {
                    $item->columns[$column] = null;
                }
            }

            // Add the item to the output
            $output[] = $item;
        }

        return $output;
    }
public function formatAutocompleteResponse ( $ results ) { $ output = [ ] ; foreach ( $ results as $ row ) { // Only keep the id and title fields $ item = new stdClass ; $ item -> id = $ row -> getKey ( ) ; $ item -> title = $ row -> getAdminTitleAttribute ( ) ; // Add properties for the columns mentioned in the list view within the // 'columns' property of this row in the response.  Use the same logic // found in Decoy::renderListColumn(); $ item -> columns = [ ] ; foreach ( $ this -> columns ( ) as $ column ) { if ( method_exists ( $ row , $ column ) ) { $ item -> columns [ $ column ] = call_user_func ( [ $ row , $ column ] ) ; } elseif ( isset ( $ row -> $ column ) ) { if ( is_a ( $ row -> $ column , 'Carbon\Carbon' ) ) { $ item -> columns [ $ column ] = $ row -> $ column -> format ( FORMAT_DATE ) ; } else { $ item -> columns [ $ column ] = $ row -> $ column ; } } else { $ item -> columns [ $ column ] = null ; } } // Add the item to the output $ output [ ] = $ item ; } return $ output ; }
Format the results of a query in the format needed for the autocomplete
responses

@param  array $results
@return array
Format the results of a query in the format needed for the autocomplete responses