Bulk Delete a collection of Models.
public bulkDelete ( array | collection $collection = [] ) : mixed | ||
$collection | array | collection | |
return | mixed |
/** * @test */ public function it_deletes_models_data_in_bulk() { $connection = \Mockery::mock(Connection::class); $connection->shouldReceive('getDefaultIndex')->once()->andReturn('plastic'); $model1 = new PersistenceModelTest(); $model2 = new PersistenceModelTest(); $collection = [$model1, $model2]; $connection->shouldReceive('bulkStatement')->once()->with(['body' => [['delete' => ['_id' => null, '_type' => 'foo', '_index' => 'bar']], ['delete' => ['_id' => null, '_type' => 'foo', '_index' => 'bar']]]]); $persistence = new EloquentPersistence($connection); $persistence->bulkDelete($collection); }