public function testIsNotificationValid()
 {
     $this->resetEvents();
     $c = $this->createCompany();
     $en = EmailNotification::createUpdateNotification("Company", $c->id, EmailNotification::COMPANY_NO_CREDIT);
     $this->assertTrue($en->isValidNotification(24 * 60 * 60));
     $en->notification_sent = date('Y-m-d H:i:s', strtotime('-1 days'));
     $en->save();
     $this->assertFalse($en->isValidNotification(24 * 60 * 60));
     $this->resetEvents();
 }
 private function sendEmailToPublisherAdminsNoCredits($publisherAdmins, $companyId)
 {
     $en = EmailNotification::findNotification("Company", $companyId, EmailNotification::COMPANY_NO_CREDIT);
     if (empty($en) || !$en->isValidNotification()) {
         Mail::send('emails.import.no_credits', [], function ($message) use($publisherAdmins) {
             $emails = array_map(function ($ar) {
                 return $ar["email"];
             }, $publisherAdmins->toApiArray());
             $message->from('*****@*****.**')->to($emails)->bcc(Config::get("mail.admins"))->subject('[MINT NOTIFICATION - NO CREDITS LEFT]');
         });
         EmailNotification::createUpdateNotification("Company", $companyId, EmailNotification::COMPANY_NO_CREDIT);
     }
 }