1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Missing files (#3412)

This commit is contained in:
David Bomba 2020-03-03 20:51:05 +11:00 committed by GitHub
parent 1393179160
commit 2085fa38dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Events\Credit;
use App\Models\Company;
use App\Models\Credit;
use Illuminate\Queue\SerializesModels;
/**
* Class CreditWasMarkedSent.
*/
class CreditWasMarkedSent
{
use SerializesModels;
/**
* @var Credit
*/
public $credit;
public $company;
/**
* Create a new event instance.
*
* @param Quote $credit
*/
public function __construct(Credit $credit, Company $company)
{
$this->credit = $credit;
$this->company = $company;
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Services\Credit;
use App\Events\Credit\CreditWasMarkedSent;
use App\Models\Credit;
class MarkSent
{
private $client;
public function __construct($client)
{
$this->client = $client;
}
public function run($credit)
{
/* Return immediately if status is not draft */
if ($credit->status_id != Credit::STATUS_DRAFT) {
return $credit;
}
$credit->markInvitationsSent();
event(new CreditWasMarkedSent($credit, $credit->company));
$credit->service()->setStatus(Credit::STATUS_SENT)->applyNumber()->save();
return $credit;
}
}