public storeMultiple ( array $notifications ) : mixed | ||
$notifications | array | |
return | mixed |
public function storeMultiple(array $notifications)
{
$this->db->beginTransaction();
$stackId = $this->db->table($this->notification->getTable())->max('stack_id') + 1;
foreach ($notifications as $key => $notification) {
$notifications[$key]['stack_id'] = $stackId;
}
$insert = $this->db->table($this->notification->getTable())->insert($notifications);
$this->db->commit();
return $insert;
}
/** @test */ function it_send_multiple_notification() { $notificationsToSend[0] = $this->buildNotification(); $notificationsToSend[1] = $this->buildNotification(); $storeMultipleNotificaations = $this->notificationRepo->storeMultiple($notificationsToSend); $notifications = Notification::all(); $this->assertCount(2, $notifications); $this->assertEquals(2, $storeMultipleNotificaations); }