@param $eloquent

@return array
505153
protected function allColumns($eloquent)
    {
        static $columns = [];

        $table = is_object($eloquent) ? $eloquent->getTable() : $eloquent;

        if (!array_has($columns, $table) || empty($columns)) {
            $columns[$table] = scheme()->columns($table);

            if ($eloquent instanceof Translatable && method_exists($eloquent, 'getTranslationModel')) {
                $translationModel = $eloquent->getTranslationModel();

                $columns[$table] = array_merge(
                    $columns[$table],
                    scheme()->columns($translationModel->getTable())
                );
            }
        }

        return array_get($columns, $table, []);
    }
971042
protected function loadRelated(): array
    {
        $innerKey = $this->parent->getField($this->key(Record::INNER_KEY));
        if (empty($innerKey)) {
            return [];
        }

        //Work with pre-build query
        $query = $this->createQuery($innerKey);

        //Use custom node to parse data
        $node = new PivotedRootNode(
            $this->schema[Record::RELATION_COLUMNS],
            $this->schema[Record::PIVOT_COLUMNS],
            $this->schema[Record::OUTER_KEY],
            $this->schema[Record::THOUGHT_INNER_KEY],
            $this->schema[Record::THOUGHT_OUTER_KEY]
        );

        $iterator = $query->getIterator();
        foreach ($iterator as $row) {
            //Time to parse some data
            $node->parseRow(0, $row);
        }

        //Memory free
        $iterator->close();

        return $node->getResult();
    }
248601
protected function hasRelation($eloquent, $id)
    {
        return (method_exists($eloquent, $id) && ($relation = $eloquent->$id())) ? $relation : null;
    }
359676
public function getModelArray(Model $model)
    {
        $result = [];
        foreach ($model->getAttributes() as $key => $value) {
            $result[] = ['type' => 'text', 'name' => $key, 'key' => $key.' :', 'value' => $value];
        }
        unset($result[0]);

        return $result;
    }
568462
public function getForm($eloquent, $type = null)
    {
        $classname     = $eloquent->classname;
        $model         = $eloquent->contents->first();
        $configuration = [
            'content'       => $model !== null ? $model->content : null,
            'title'         => $model !== null ? $model->title : '',
            'type'          => $eloquent->exists ? $eloquent->type->name : '',
            'form_name'     => $eloquent->name
        ];
        $notification  = app($classname ?: Notification::class);

        $fluent        = new Fluent(array_merge($configuration, array_except($eloquent->toArray(), ['type'])));
        if (!is_null($fluent->type) && $type) {
            $fluent->type = $type;
        }

        return $this->form($fluent, $notification);
    }
1265630
public function q_pairs($q): array
    {
        $res = [];
        $qh = $this->sql_query($q);

        while ($q = $qh->fetch(PDO::FETCH_NUM)) {
            if (isset($q[1])) {
                $res[$q[0]] = $q[1];
            } else {
                $res[] = $q[0];
            }
        }

        return $res;
    }
193666
protected function inputType($column, $eloquent)
    {
        static $columns = [];

        if (method_exists($this, 'inputTypes')
            && array_key_exists($column, $types = $this->inputTypes())
        ) {
            return $types[$column];
        }

        if ($eloquent instanceof AttachableInterface
            && array_key_exists($column, $attachments = $eloquent->getAttachedFiles())
        ) {
            return $this->getAttachmentType($column, $attachments);
        }

        $columns = array_merge($columns, $this->allColumns($eloquent));

        // map column database type to input type
        if ($column = array_get($columns, $column)) {
            return $this->mapColumnTypeToFieldType($column);
        }

        if ($chain = $this->isRelationColumn($column)) {
            list($relColumn, $table) = $this->resolveRelationsChain($chain, $eloquent);

            return $this->inputType($relColumn, $table->getRelated());
        }

        return 'text';
    }
301328
public static function fromTableSchema(TableSchema $schema)
    {
        $properties = [];
        $required = [];
        foreach ($schema->getColumns() as $column) {
            if ($column->getRequired()) {
                $required[] = $column->getName();
            }

            $properties[$column->getName()] = static::fromColumnSchema($column);
        }

        return [
            'type'       => 'object',
            'required'   => $required,
            'properties' => $properties
        ];
    }
637728
public function getArrguments()
    {
        return [
            'model-name' => $this->modelName,
            '--table-name' => $this->tableName,
            '--connection-name' => $this->connectionName,
            '--engine-name' => $this->engineName,
            '--resource-file' => $this->resourceFile,
            '--template-name' => $this->template,
            '--without-timestamps' => $this->withoutTimestamps,
            '--with-soft-delete' => $this->withSoftDelete,
        ];
    }
1216447
public function setModel($eloquent, $table)
    {
        self::$_pathToClass = $eloquent;
        self::$_modelTable = $table;

        return $this;
    }
1269239
public function getEmptyValueForLocalKey(string $relation)
    {
        if ($this->isPolymorphic($relation)) {
            $key = $this->localForeignKeys[$relation];

            return [
                $key['type'] => null,
                $key['id']   => null,
            ];
        }

        if ($this->isManyRelationship($relation)) {
            return [];
        }
    }
382857
public function transform(Timeslot $model)
    {
        return [
            'id'         => (int) $model->id,

            /* place your other model properties here */

            'created_at' => $model->created_at,
            'updated_at' => $model->updated_at
        ];
    }
627065
protected function formatScopes($unformatted = [])
    {
        if (is_null($unformatted)) {
            return [];
        }

        $scopes = [];
        foreach ($unformatted as $scope) {
            if ($scope instanceof ScopeEntity) {
                $scopes[$scope->getId()] = $scope;
            }
        }

        return $scopes;
    }
206886
public function onEdit(Model $eloquent)
    {
        $this->onList();
        $title  = null;
        $langId = lang_id();
        foreach ($eloquent->contents as $content) {
            if ($langId == $content->lang_id) {
                $title = $content->title;
            }
        }
        Breadcrumbs::register('notification-edit', function($breadcrumbs) use($title) {
            $breadcrumbs->parent('notifications');
            $breadcrumbs->push(trans('antares/notifications::messages.notification_templates_edit', ['name' => $title]));
        });

        view()->share('breadcrumbs', Breadcrumbs::render('notification-edit'));
    }
795553
public function formatInvoice($oInvoice)
    {
        return [
            'id'       => $oInvoice->id,
            'ref'      => $oInvoice->ref,
            'terms'    => $oInvoice->terms,
            'dated'    => $oInvoice->dated->raw,
            'due'      => $oInvoice->due->raw,
            'paid'     => $oInvoice->paid->raw,
            'state'    => $oInvoice->state,
            'currency' => $oInvoice->currency->code,
            'totals'   => $oInvoice->totals,
            'urls'     => $oInvoice->urls,
            'customer' => empty($oInvoice->customer) ? null : [
                'id'    => $oInvoice->customer->id,
                'label' => $oInvoice->customer->label,
            ],
        ];
    }
1132336
protected function _parseRelation($relation)
    {
        $scope = null;
        if (strpos($relation, ':') !== false) {
            list($relation, $scope) = explode(':', $relation);
        }

        return [$relation, $scope];
    }
535304
protected function getTableAndDatabase($model)
    {
        $table = $model->getConnection()->getTablePrefix() . $model->getTable();

        $database = null;

        if (strpos($table, '.')) {
            list($database, $table) = explode('.', $table);
        }

        return [$table, $database];
    }