Components\ReportBuilder\Controllers\Backend\ReportBuilderController::getModuleFields PHP Method

getModuleFields() public method

Get all the fields that are available in a module
public getModuleFields ( integer $id ) : array
$id integer Module ID
return array The fields in the module
    public function getModuleFields($id)
    {
        $module = Module::find($id);
        $vendor = $module->vendor ? $module->vendor . '/' : '';
        $json_file = app_path() . '/Modules/' . $vendor . $module->alias . '/module.json';
        $config = json_decode(file_get_contents($json_file), true);
        $fieldAndNames = array();
        foreach ($config['forms'] as $form) {
            $fields = array_combine($form['fields'], $form['field_names']);
            $fields['created_at'] = 'Created At';
            $fields['updated_at'] = 'Updated At';
            if (array_key_exists('form_name', $form)) {
                $form_info = array('name' => $form['form_name'], 'model' => $form['model'], 'fields' => $fields);
                $fieldAndNames[] = $form_info;
            }
        }
        return Response::json($fieldAndNames);
    }