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

97 lines
2.2 KiB
PHP
Raw Normal View History

2019-04-04 01:17:15 +02:00
<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
2019-05-11 05:32:07 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
2019-04-04 01:17:15 +02:00
namespace App\Repositories;
use App\Events\Invoice\InvoiceWasDeleted;
2019-05-29 06:33:53 +02:00
use App\Factory\InvoiceInvitationFactory;
use App\Jobs\Product\UpdateOrCreateProduct;
2020-02-26 06:18:38 +01:00
use App\Models\Client;
2019-09-23 05:22:24 +02:00
use App\Models\ClientContact;
2019-04-04 01:17:15 +02:00
use App\Models\Invoice;
2019-05-29 06:33:53 +02:00
use App\Models\InvoiceInvitation;
2019-09-23 05:22:24 +02:00
use App\Utils\Traits\MakesHash;
2019-04-04 01:17:15 +02:00
/**
* InvoiceRepository
2019-04-04 01:17:15 +02:00
*/
class InvoiceRepository extends BaseRepository
{
use MakesHash;
/**
* Gets the class name.
*
* @return string The class name.
*/
public function getClassName()
{
return Invoice::class ;
}
/**
* Saves the invoices
*
* @param array. $data The invoice data
* @param InvoiceSum|\App\Models\Invoice $invoice The invoice
*
* @return Invoice|InvoiceSum|\App\Models\Invoice|null Returns the invoice object
*/
public function save($data, Invoice $invoice):?Invoice
{
return $this->alternativeSave($data, $invoice);
}
/**
* Mark the invoice as sent.
*
* @param \App\Models\Invoice $invoice The invoice
*
* @return Invoice|\App\Models\Invoice|null Return the invoice object
*/
public function markSent(Invoice $invoice):?Invoice
{
return $invoice->service()->markSent()->save();
}
public function getInvitationByKey($key) :?InvoiceInvitation
{
return InvoiceInvitation::whereRaw("BINARY `key`= ?", [$key])->first();
}
public function delete($invoice)
{
if ($invoice->is_deleted) {
return;
}
$invoice->is_deleted = true;
$invoice->save();
$invoice->delete();
if (class_exists($className)) {
event(new InvoiceWasDeleted($invoice));
}
}
public function reverse()
{
}
public function cancel()
{
}
}