} switch ($this->frequency_id) { case FREQUENCY_WEEKLY: return $daysSinceLastSent >= 7; case FREQUENCY_TWO_WEEKS: return $daysSinceLastSent >= 14; case FREQUENCY_FOUR_WEEKS: return $daysSinceLastSent >= 28; case FREQUENCY_MONTHLY: return $monthsSinceLastSent >= 1; case FREQUENCY_THREE_MONTHS: return $monthsSinceLastSent >= 3; case FREQUENCY_SIX_MONTHS: return $monthsSinceLastSent >= 6; case FREQUENCY_ANNUALLY: return $monthsSinceLastSent >= 12; default: return false; } return false; } } Invoice::created(function ($invoice) { Activity::createInvoice($invoice); }); Invoice::updating(function ($invoice) { Activity::updateInvoice($invoice); }); Invoice::deleting(function ($invoice) { Activity::archiveInvoice($invoice); });
return $daysSinceLastSent >= 14; case FREQUENCY_FOUR_WEEKS: return $daysSinceLastSent >= 28; case FREQUENCY_MONTHLY: return $monthsSinceLastSent >= 1; case FREQUENCY_THREE_MONTHS: return $monthsSinceLastSent >= 3; case FREQUENCY_SIX_MONTHS: return $monthsSinceLastSent >= 6; case FREQUENCY_ANNUALLY: return $monthsSinceLastSent >= 12; default: return false; } return false; } } Invoice::created(function ($invoice) { if (!$invoice->is_recurring) { $invoice->branch->incrementCounter($invoice->is_quote); $invoice->account->incrementCounter($invoice->is_quote); } Activity::createInvoice($invoice); BookSale::createBook($invoice); }); Invoice::updating(function ($invoice) { Activity::updateInvoice($invoice); }); Invoice::deleting(function ($invoice) { Activity::archiveInvoice($invoice); });
switch ($this->frequency_id) { case FREQUENCY_WEEKLY: return $daysSinceLastSent >= 7; case FREQUENCY_TWO_WEEKS: return $daysSinceLastSent >= 14; case FREQUENCY_FOUR_WEEKS: return $daysSinceLastSent >= 28; case FREQUENCY_MONTHLY: return $monthsSinceLastSent >= 1; case FREQUENCY_THREE_MONTHS: return $monthsSinceLastSent >= 3; case FREQUENCY_SIX_MONTHS: return $monthsSinceLastSent >= 6; case FREQUENCY_ANNUALLY: return $monthsSinceLastSent >= 12; default: return false; } return false; } } Invoice::created(function ($invoice) { $invoice->branch->incrementCounter($invoice->is_quote); Activity::createInvoice($invoice); }); Invoice::updating(function ($invoice) { Activity::updateInvoice($invoice); }); Invoice::deleting(function ($invoice) { Activity::archiveInvoice($invoice); });