mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
659af63b5c
* Skip preview tests * Fixes for product test * Fixes for tests * Update README.md * Update README.md * Update README.md * Update README.md * Fixes for incorrect payment types * Refactor class nameS * Entity Notification refactor * Entity Notifications * Add Quotes to randomdataseederr
41 lines
805 B
PHP
41 lines
805 B
PHP
<?php
|
|
|
|
namespace App\Services\Credit;
|
|
|
|
use App\Events\Credit\CreditWasMarkedSent;
|
|
use App\Models\Credit;
|
|
|
|
class MarkSent
|
|
{
|
|
private $client;
|
|
|
|
private $credit;
|
|
|
|
public function __construct($client, $credit)
|
|
{
|
|
$this->client = $client;
|
|
$this->credit = $credit;
|
|
}
|
|
|
|
public function run()
|
|
{
|
|
|
|
/* Return immediately if status is not draft */
|
|
if ($this->credit->status_id != Credit::STATUS_DRAFT) {
|
|
return $this->credit;
|
|
}
|
|
|
|
$this->credit->markInvitationsSent();
|
|
|
|
event(new CreditWasMarkedSent($this->credit, $this->credit->company));
|
|
|
|
$this->credit
|
|
->service()
|
|
->setStatus(Credit::STATUS_SENT)
|
|
->applyNumber()
|
|
->save();
|
|
|
|
return $this->credit;
|
|
}
|
|
}
|