1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 06:32:40 +01:00
invoiceninja/app/Services/Credit/MarkSent.php
David Bomba 43e57d0117
Fixes for self-update (#3514)
* minor fix for payment notifications

* styleci

* Limit Self updating to self hosters only
:

* Fixes for designs

* Minor fixes for self-update
2020-03-21 16:37:30 +11:00

37 lines
749 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;
}
}