@param Record $record
@param Entity $entity

@return $this
976716
public function insert(Record $record, Entity $entity)
    {
        (new InsertRecord($record, $entity, $this))->execute();

        return $this;
    }
226189
public function log(\Imi\Log\Record $record)
    {
        if(in_array($record->getLevel(), $this->levels))
        {
            $this->records[] = $record;
            $this->trySave();
        }
    }
163841
final public static function instantiate (array $record)
	{
		$className 	= get_called_class();
		$object 	= new $className;
		foreach ($record as $attribute => $value):
			$object->$attribute = $value;
		endforeach;
		return $object;
	}
593145
private function processEntities($entities, $operation, callable $callback, $entityClass = null)
    {
        $filterByEntityClass = !empty($entityClass);

        foreach ($entities as $entity) {
            if (!$filterByEntityClass || $entity instanceof $entityClass) {
                $callback($entity, $operation);
            }
        }

        return $this;
    }
797489
public function removeRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record)
    {
        return $this->records->removeElement($record);
    }
763407
public function duplicate(Entity $entity = null)
    {
        $entity = $this->getEntityIfEmpty($entity);

        $data = $this->toArray();
        if (isset($data['id'])) {
            unset($data['id']);
        }

        foreach ($data as $key => &$val) {
            if ($key && array_key_exists($key . '_x', $data) && array_key_exists($key . '_y', $data)) {
                $val = [
                    $data[$key . '_x'],
                    $data[$key . '_y'],
                ];
            }
        }

        $record = new static($data);
        $record->save($entity);

        return $record;
    }
306638
public static function getOrCreate(array $data, Entity $entity = null)
    {
        $record = static::gets($data, $entity);

        if (!$record) {
            $record = static::create($data, $entity);
        }

        return $record;
    }
412190
public function setListParent($relation, $recordKey = null)
    {
        if (false !== $relation && empty($relation)) {
            return $this->clearListParent();
        }

        if (false === $relation) {
            session()->put($this->getSessionKey(static::TYPE_PARENT), static::PARENT_DISABLE);
        } else {
            session()->put($this->getSessionKey(static::TYPE_PARENT), $relation . ':' . $recordKey);
        }

        return $this;
    }
1314262
public function save(Entity $entity, $attributes = array())
    {
        foreach ($attributes as $key => $value) {
            $entity->$key = $value;
        }

        // when new record.
        if ($entity->isNew()) {
            $new = $this->create($entity->toArray());
            $entity->exists = true;
            $entity->setPrimaryValue($new->getPrimaryValue());
        }

        // when update.
        else {
            $attributes = $entity->getAttributes(true);
            if (! $attributes ) return;

            return $this->update($attributes, $entity->getPrimaryValue());
        }
    }
144108
public function remove(Entity $entity) {
    if (method_exists($entity,'remove')) {
      $entity->remove();
    }
    $this->_em->remove($entity);
    
    return $this;
  }
1153764
public function publish(Request $request, $entity, $record = null, $child = null)
    {
        if (!$record && !$child && ($entityObject = Entity::fromYamlFile($entity))) {
        } elseif (($parentEntity = Entity::fromYamlFile($entity)) && ($entityObject = Entity::fromYamlFile($child))) {
            // Get parent's record
            $parentRecord = $parentEntity->class::findOrFail($record);
        } else {
            abort(404);
        }

        // Get validation from entity rules and validate
        $this->validate($request, $this->validationRules($entityObject->fields));

        // If data is validated and everything seems good, lets create the record
        $record = new $entityObject->class();

        foreach ($entityObject->fields as $field => $options) {
            $type = ucwords($options['type']);
            $className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';

            if (!isset($className::$ignore) || !$className::$ignore) {
                $record->$field = $request->input($field);
            }
        }

        // Save slug
        if (isset($entityObject->slug['field']) && $entityObject->slug['field'] &&
            isset($entityObject->slug['column']) && $entityObject->slug['column']) {
            $field = $entityObject->slug['field'];
            $column = $entityObject->slug['column'];

            $record->$column = str_slug($record->$field,
                                            isset($entityObject->slug['separator']) ? $entityObject->slug['separator'] : '-');
        }

        // Save parent
        if (isset($parentRecord) && $parentRecord) {
            $row = snake_case(class_basename($parentEntity->class)).'_id';

            $record->$row = $parentRecord->id;
        }

        $record->save();

        foreach ($entityObject->fields as $field => $options) {
            $type = ucwords($options['type']);
            $className = 'Jaimeeee\\Panel\\Fields\\'.$type.'\\'.$type.'Field';

            // Lets see if the call method exists, and if it does, we should trust the field ¯\_(ツ)_/¯
            if (method_exists($className, 'call')) {
                $className::call($request, $record, $field, $options);
            }
        }

        $record->save();

        // Upload single images
        // $this->uploadImages($request, $record, $entityObject);

        if (isset($parentRecord) && $parentRecord) {
            return redirect(config('panel.url').'/'.$parentEntity->url.'/'.$parentRecord->id.'/'.$entityObject->url.'?created=1');
        } else {
            return redirect(config('panel.url').'/'.$entityObject->url.'?created=1');
        }
    }
82419
public function setEntity($entity, $entityId)
    {
        //set the entity
        $method = 'set'.ucfirst($entityId);

        //set the entity
        call_user_func([$this, $method], $entity);
    }
656087
protected function processRecord(Record $record)
    {

        foreach ($this->processors as $processor) {
            if ($this->isInstanceOf($processor, ProcessorInterface::class)) {
                $processor->processRecord($record);
            } else {
                call_user_func($processor, $record);
            }
        }
    }
893563
public function get_author_from_stdclass(stdClass $record) : author_entity {
        return new author_entity(
            $record->id,
            $record->picture,
            $record->firstname,
            $record->lastname,
            fullname($record),
            $record->email,
            $record->middlename,
            $record->firstnamephonetic,
            $record->lastnamephonetic,
            $record->alternatename,
            $record->imagealt
        );
    }
346635
final public function page($pageNumber, $recordsPerPage = null)
    {
        $recordsPerPage = $recordsPerPage ?? $this->recordsPerPage;

        $this->getQuery()->limit(((int)$pageNumber) * $recordsPerPage, $recordsPerPage);
        $this->pagedQuery = true;

        return $this;
    }
133504
public function fillRecord(Record $record)
    {
        /**
         * Get record from right entity.
         */
        $rightRecord = $this->getRightRecord(
            $this->getRightEntity(),
            $this->primaryKey,
            $record->{$this->foreignKey}
        );

        /**
         * Set relation.
         */
        $record->setRelation($this->fill, $rightRecord);

        /**
         * Fill relations.
         */
        $this->fillRecordWithRelations($record);
    }
818395
public function pushRecord(Record $record)
    {
        switch (true) {
            case $record->getType()->isStdout():
                $this->stdout .= $record->getContent();
                break;
            case $record->getType()->isStderr():
                $this->stderr .= $record->getContent();
                break;
            case $record->getType()->isEndRequest():
                return new Response($this->requestId, new StringReader($this->stdout), new StringReader($this->stderr));
                break;
            default:
                throw new \RuntimeException(sprintf('Unknown package type \'%d\'', $record->getType()));
                break;
        }
    }