Prepares the datatable data.

@return \Illuminate\Http\JsonResponse
977887
public function ajax()
    {
        $acl       = app('antares.acl')->make('antares/ban_management');
        $canUpdate = $acl->can('update-rule');
        $canDelete = $acl->can('delete-rule');

        $today = Carbon::today();

        /* @var $searchQuery SearchQuery */
        $searchQuery = app()->make(SearchQuery::class);

        return $this->prepare()
                        ->filter(function($query) use($searchQuery) {
                            $searchQuery->apply(function($keyword) use($query) {
                                $query->leftJoin('tbl_users', 'tbl_ban_management_rules.user_id', '=', 'tbl_users.id');
                                $query->where(function($q) use($keyword) {
                                    $q->where('tbl_ban_management_rules.value', 'like', "%$keyword%");
                                    $q->orWhere('tbl_ban_management_rules.created_at', 'like', "%$keyword%");
                                    $q->orWhere('tbl_ban_management_rules.expired_at', 'like', "%$keyword%");
                                    $q->orWhere('tbl_ban_management_rules.internal_reason', 'like', "%$keyword%");
                                    $q->orWhere('tbl_users.firstname', 'like', "%$keyword%");
                                    $q->orWhere('tbl_users.lastname', 'like', "%$keyword%");
                                });
                            });
                        })
                        ->filterColumn('status', function($query, $keyword) {
                            $value = null;
                            switch ($keyword) {
                                case 'expired':
                                    $query->whereRaw('(tbl_ban_management_rules.expired_at < "' . date('Y-m-d H:i:s', time()) . '")');
                                    break;
                                case 'active':
                                    $query->whereRaw('(tbl_ban_management_rules.expired_at > "' . date('Y-m-d H:i:s', time()) . '")');
                                    break;
                            }
                        })
                        ->editColumn('enabled', function (Rule $rule) {
                            return $rule->isEnabled() ? '<span class="label-basic label-basic--success">YES</span>' : '<span class="label-basic label-basic--danger">NO</span>';
                        })
                        ->editColumn('trusted', function (Rule $rule) {
                            return $rule->isTrusted() ? '<span class="label-basic label-basic--success">YES</span>' : '<span class="label-basic label-basic--danger">NO</span>';
                        })
                        ->editColumn('user_id', function (Rule $rule) {
                            return $rule->user ? $rule->user->fullname : '---';
                        })
                        ->editColumn('internal_reason', function (Rule $rule) {
                            return strlen($rule->getInternalReason()) <= 0 ? '---' : $rule->getInternalReason();
                        })
                        ->editColumn('created_at', function (Rule $rule) {
                            return format_x_days($rule->getCreationDate());
                        })
                        ->editColumn('expired_at', function (Rule $rule) {
                            return $rule->getPresenter()->getFormattedExpirationDate();
                        })
                        ->editColumn('status', function (Rule $rule) use($today) {
                            if (!$rule->isEnabled()) {
                                return '<span class="label-basic label-basic--danger">' . trans('antares/ban_management::datagrid.header.disabled') . '</span>';
                            }

                            return $rule->isActive($today) ? '<span class="label-basic label-basic--success">' . trans('antares/ban_management::datagrid.header.active') . '</span>' : '<span class="label-basic label-basic--danger">' . trans('antares/ban_management::datagrid.header.expired') . '</span>';
                        })
                        ->addColumn('action', $this->getActionsColumn($canUpdate, $canDelete))
                        ->make(true);
    }
877392
public function prepare()
    {
        if (null === $this->getAttribute('id')) {
            $this->setAttribute('id', 'pop-form');
        }
        if (null === $this->getAttribute('class')) {
            $this->setAttribute('class', 'pop-form');
        }
        if (count($this->columns) > 0) {
            foreach ($this->columns as $class => $fieldsets) {
                $column = new Child('div');
                $column->setAttribute('class', $class);
                foreach ($fieldsets as $i) {
                    if (isset($this->fieldsets[$i])) {
                        $fieldset = $this->fieldsets[$i];
                        $fieldset->prepare();
                        $column->addChild($fieldset);
                    }
                }
                $this->addChild($column);
            }
        } else {
            foreach ($this->fieldsets as $fieldset) {
                $fieldset->prepare();
                $this->addChild($fieldset);
            }
        }
        return $this;
    }
922516
public function dataTable()
    {
        return (new EloquentDataTable($this->query()))
            ->editColumn('authenticated', function (Widget $widget) {
                return view('administrator.widgets.datatables.authenticated', $widget->toArray());
            })
            ->editColumn('title', function (Widget $widget) {
                return html()->linkRoute('administrator.widgets.edit', $widget->title, $widget);
            })
            ->editColumn('template', function (Widget $widget) {
                return '<code>' . implode('/', explode('.', $widget->present()->template)) . '.blade.php' . '</code>';
            })
            ->editColumn('position', function (Widget $widget) {
                return '<span class="badge bg-orange">' . $widget->position . '</span>';
            })
            ->editColumn('action', function (Widget $widget) {
                return view('administrator.widgets.datatables.action', $widget->toArray());
            })
            ->editColumn('created_at', function (Widget $category) {
                return $category->created_at->format('Y-m-d');
            })
            ->rawColumns(['published', 'authenticated', 'action', 'template', 'position']);
    }
1069520
protected function prepareTable()
    {
        if (!$this->schema->hasTable($this->table)) {
            $this->schema->table($this->table)
                ->string('id', 128)
                ->timestamp('created_at')
                ->exec();
        }
    }
210914
public function jsonSerialize() {
		$json = array();

		foreach(get_object_vars($this) as $var => $val) {
			if($val instanceof \DateTime)
				$json[$var] = $val->getTimestamp();
			else
				$json[$var] = $val;
		}

		return $json;
	}
235428
public function render()
    {

        $this->scripts();
        $dataProvider     = $this->prepareData();
        $this->attributes = array_merge($this->attributes, [
            'dataProvider' => $dataProvider,
            'emptyUrl'     => $this->emptyUrl()
        ]);
        if (!is_null($this->attributes['selected'])) {
            $this->attributes['selected'] = $dataProvider->where('id', (int) $this->attributes['selected'])->first()['name'];
        } else {
            $this->attributes['selected'] = $this->attributes['title'];
        }

        $view = view('view-helpers::filter-dropdown', $this->attributes);
        return $view->render();
    }
492040
public function prepare() {
        $sql = $this->getSql();
        $params = array_merge($this->whereParams(), $this->having_params);
        return [$sql, $params];
    }
350864
public function jsonSerialize()
    {
        return array(
            self::SOURCE_FACTORY => $this->metadataDaoFactory,
            self::FACTORY        => $this->driver,
            self::RESPONSE       => $this->response,
            self::UNIQUE_NAME    => $this->uniqueName,
        );
    }
913756
public function data()
    {
        $ratings = RatingTotalModel::with([
            'rateable' => function ($query) {
                $query->with(['ratings', 'ratingTotal'])->select(['id', 'title', 'slug']);
            }])->get();

        $ratings = $ratings->filter(function ($value, $key) {
            return isset($value->rateable);
        });

        $resource = (new RatingTransformer())->transformCollection($ratings);

        return DataTables::of(collect($this->serializeToArray($resource)))
            ->rawColumns(['actions'])
            ->make();
    }
346589
protected function prepareData()
    {
        if ($this->prepared) {
            return;
        }

        $this->presences         = new Collection;
        $this->modulePresences   = new Collection;
        $this->permissions       = [];
        $this->modulePermissions = [];

        $this->loadAclModules()
             ->collapsePermissions();

        $this->prepared = true;
    }
506595
public function explain()
    {
        $data     = $this->buildData();
        $response = $this->_connection->post(Urls::URL_EXPLAIN, $this->getConnection()->json_encode_wrapper($data), []);

        return $response->getJson();
    }
1297564
public function renderJson()
    {
        $totalCount = $this->getDatasource()->totalCount();
        $rows = $this->getDatasource()->listRows();

        $tmpData = [];
        foreach ($rows as $row) {
            $tmp = [];

            $this->currentRow = new DefaultRow();
            if ($this->rowCallback instanceof \Closure) {
                $this->rowCallback->call($this, $row);
            }

            foreach ($this->getColumns() as $key => $column) {
                $this->currentColumn = $key;
                $tmp[$column->getName()] = $column->format($row);
            }

            $tmpData[] = $tmp;
        }

        $data = [
            'draw' => $this->getRequest()->get('draw'), // @todo param names configurable
            'recordsTotal' => $totalCount,
            'recordsFiltered' => $totalCount,
            'data' => $tmpData,
        ];

        header('Content-Type: application/json');
        echo json_encode($data);die;
    }
441256
protected function _prepareForm()
    {
        $model = $this->getModel();

        /** @var \Magento\Framework\Data\Form $form */
        $form = $this->_formFactory->create(
            ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
        );

        $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information')]);

        if ($model->getId()) {
            $fieldset->addField('thesaurus_id', 'hidden', ['name' => 'thesaurus_id']);
        }

        if ($model->getType()) {
            $fieldset->addField('type', 'hidden', ['name' => 'type']);
        }

        $this->initBaseFields($fieldset);
        $this->initTypeFields($fieldset, $model);

        $form->setValues($model->getData());

        $form->setUseContainer(true);
        $this->setForm($form);

        return parent::_prepareForm();
    }
448182
public function prepare()
    {
        if (is_array($this->dataPrepared)) {
            return false;
        }

        $data = $this->data;

        foreach ($data as $key => &$row) {
            $row = (array) $row;

            $ids = [];

            foreach ($this->getColumns() as $col) {
                /* @var $col \ZfcDatagrid\Column\AbstractColumn */

                if (isset($row[$col->getUniqueId()]) && $col->isIdentity() === true) {
                    $ids[] = $row[$col->getUniqueId()];
                }

                /*
                 * Maybe the data come not from another DataSource?
                 */
                if ($col instanceof Column\ExternalData) {
                    /* @var $col \ZfcDatagrid\Column\ExternalData */
                    // @todo improve the interface...
                    $dataPopulation = $col->getDataPopulation();

                    foreach ($dataPopulation->getObjectParametersColumn() as $parameter) {
                        $dataPopulation->setObjectParameter(
                            $parameter['objectParameterName'],
                            $row[$parameter['column']->getUniqueId()]
                        );
                    }
                    $row[$col->getUniqueId()] = $dataPopulation->toString();
                }

                if (! isset($row[$col->getUniqueId()])) {
                    $row[$col->getUniqueId()] = '';
                }

                /*
                 * Replace
                 */
                if ($col->hasReplaceValues() === true) {
                    $replaceValues = $col->getReplaceValues();

                    if (is_array($row[$col->getUniqueId()])) {
                        foreach ($row[$col->getUniqueId()] as &$value) {
                            if (isset($replaceValues[$value])) {
                                $value = $replaceValues[$value];
                            } elseif ($col->notReplacedGetEmpty() === true) {
                                $value = '';
                            }
                        }
                    } else {
                        if (isset($replaceValues[$row[$col->getUniqueId()]])) {
                            $row[$col->getUniqueId()] = $replaceValues[$row[$col->getUniqueId()]];
                        } elseif ($col->notReplacedGetEmpty() === true) {
                            $row[$col->getUniqueId()] = '';
                        }
                    }
                }

                /*
                 * Type converting
                 */
                if ($this->getRendererName() != 'PHPExcel') {
                    $row[$col->getUniqueId()] = $col->getType()->getUserValue($row[$col->getUniqueId()]);
                }

                /*
                 * Translate (nach typ convertierung -> PhpArray...)
                 */
                if ($col->isTranslationEnabled() === true) {
                    if (is_array($row[$col->getUniqueId()])) {
                        foreach ($row[$col->getUniqueId()] as &$value) {
                            if (is_array($value)) {
                                continue;
                            }
                            $value = $this->getTranslator()->translate($value);
                        }
                    } else {
                        $row[$col->getUniqueId()] = $this->getTranslator()->translate($row[$col->getUniqueId()]);
                    }
                }

                /*
                 * Trim the values
                 */
                if (is_array($row[$col->getUniqueId()])) {
                    array_walk_recursive($row[$col->getUniqueId()], function (&$value) {
                        if (! is_object($value)) {
                            $value = trim($value);
                        }
                    });
                } elseif (! is_object($row[$col->getUniqueId()])) {
                    $row[$col->getUniqueId()] = trim($row[$col->getUniqueId()]);
                }

                /*
                 * Custom formatter
                 */
                if ($col->hasFormatters() === true) {
                    foreach ($col->getFormatters() as $formatter) {
                        $formatter->setRowData($row);
                        $formatter->setRendererName($this->getRendererName());

                        $row[$col->getUniqueId()] = $formatter->format($col);
                    }
                }
            }

            // Concat all identity columns
            if (!empty($ids)) {
                $data[$key]['idConcated'] = implode('~', $ids);
            }
        }

        $this->dataPrepared = $data;

        return true;
    }
133207
protected function prepareDataProvider()
    {
        $requestParams = Yii::$app->getRequest()->getParsedBody();
        if (empty($requestParams)) {
            $requestParams = Yii::$app->getRequest()->getQueryParams();
        }

        $filter = null;
        if ($this->dataFilter !== null) {
            $this->dataFilter = Yii::createObject($this->dataFilter);
            if ($this->dataFilter->load($requestParams)) {
                $filter = $this->dataFilter->build();
                if ($filter === false) {
                    return $this->dataFilter;
                }
            }
        }

        if ($this->prepareDataProvider !== null) {
            return call_user_func($this->prepareDataProvider, $this, $filter);
        }

        /* @var $modelClass \yii\db\BaseActiveRecord */
        $modelClass = $this->modelClass;

        $query = $modelClass::find();
        if (!empty($filter)) {
            $query->andWhere($filter);
        }

        return Yii::createObject([
            '__class' => ActiveDataProvider::class,
            'query' => $query,
            'pagination' => [
                'params' => $requestParams,
            ],
            'sort' => [
                'params' => $requestParams,
            ],
        ]);
    }
958762
public function json()
    {
        $this->response->data = json_decode($this->response->body);

        return $this->response;
    }
1368931
public function prepare()
    {
        $result = [];
        foreach (config('setup.create_user.fields') as $column => $title)
        {
            $result[$column] = $this->command->ask($title);

            if ($column == config('setup.create_user.password_field'))
            {
                $result[$column] = bcrypt($result[$column]);
            }
        }

        $result['__table'] = $this->getTable(config('setup.create_user.table'));

        return $result;
    }