Пример #1
0
 /**
  * Convert models to eloquent models.
  *
  * @param \ProAI\Datamapper\Support\Collection $object
  * @return \ProAI\Datamapper\Eloquent\Collection
  */
 public static function newFromEntity($entities)
 {
     $eloquentModels = new static();
     foreach ($entities as $name => $item) {
         $eloquentModels->put($name, Model::newFromEntity($item));
     }
     return $eloquentModels;
 }
Пример #2
0
 /**
  * Delete an entity object.
  *
  * @param object $entity
  * @return \ProAI\Datamapper\Eloquent\Model
  */
 protected function getEloquentModel($entity, $exists = false)
 {
     if (empty($entity)) {
         throw new Exception('Object transfered to EntityManager is empty');
     }
     if (!is_object($entity)) {
         throw new Exception('Object transfered to EntityManager is not an object');
     }
     $eloquentModel = Model::newFromEntity($entity);
     $eloquentModel->exists = $exists;
     return $eloquentModel;
 }