1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Services/Quote/MarkSent.php

52 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2020-07-01 03:06:40 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2020-07-01 03:06:40 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2020-07-01 03:06:40 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\Quote;
use App\Events\Quote\QuoteWasMarkedSent;
use App\Models\Quote;
2020-07-08 14:02:16 +02:00
use App\Utils\Ninja;
class MarkSent
{
private $client;
private $quote;
public function __construct($client, $quote)
{
$this->client = $client;
$this->quote = $quote;
}
public function run()
{
/* Return immediately if status is not draft */
if ($this->quote->status_id != Quote::STATUS_DRAFT) {
return $this->quote;
}
$this->quote->markInvitationsSent();
2020-07-08 14:02:16 +02:00
event(new QuoteWasMarkedSent($this->quote, $this->quote->company, Ninja::eventVars()));
$this->quote
->service()
->setStatus(Quote::STATUS_SENT)
->applyNumber()
2021-03-10 11:00:18 +01:00
->deletePdf()
->save();
return $this->quote;
}
}