/** * Create a new model through eloquent model for mocking. * * @param string $table * @param array $values * @return void */ public function insertOn(string $table, array $attributes = []) { $entity = Entity::where('name', $table)->first(); if (!$entity) { $entity = Entity::create(['name' => $table]); } $object = $entity->objects()->save(new Object()); foreach ($attributes as $field => $value) { $attribute = $entity->attributes()->where(['name' => $field])->first(); if (!$attribute) { $attribute = $entity->attributes()->save(new Attribute(['name' => $field])); } $object->values()->save(new Value(['content' => $value, 'attribute_id' => $attribute->id])); } }