2020-02-11 21:57:25 +01:00
|
|
|
<?php
|
2020-05-09 00:35:49 +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)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
2020-02-11 21:57:25 +01:00
|
|
|
namespace App\Factory;
|
|
|
|
|
|
|
|
use App\Models\Invoice;
|
|
|
|
use App\Models\Quote;
|
|
|
|
|
|
|
|
class CloneQuoteToInvoiceFactory
|
|
|
|
{
|
2020-02-19 21:44:12 +01:00
|
|
|
public static function create(Quote $quote, $user_id) : ?Invoice
|
2020-03-21 06:37:30 +01:00
|
|
|
{
|
2020-05-09 00:35:49 +02:00
|
|
|
|
|
|
|
$invoice = new Invoice();
|
|
|
|
|
|
|
|
$quote_array = $quote->toArray();
|
|
|
|
|
|
|
|
unset($quote_array['client']);
|
|
|
|
unset($quote_array['company']);
|
|
|
|
unset($quote_array['hashed_id']);
|
|
|
|
unset($quote_array['id']);
|
|
|
|
|
|
|
|
foreach($quote_array as $key => $value)
|
|
|
|
$invoice->{$key} = $value;
|
|
|
|
|
|
|
|
$invoice->due_date = null;
|
|
|
|
$invoice->partial_due_date = null;
|
|
|
|
$invoice->number = null;
|
|
|
|
$invoice->status_id = null;
|
|
|
|
|
|
|
|
return $invoice;
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2020-02-11 21:57:25 +01:00
|
|
|
}
|