1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/app/Utils/Traits/SavesDocuments.php
David Bomba 74a6c4f2ee
Reminders (#3630)
* Performance improvements moving from str_replace to strtr

* Remove legacy docs

* Clean up credit transformer

* Working on invoice emails

* Clean up for invoice designs

* Tests for light and dark theme emails

* Working on reminder scheduling

* Reminder Job Class

* Fixes for github actions

* PHP CS

* Test for reminders

* Test for reminders
2020-04-15 10:30:52 +10:00

45 lines
1.1 KiB
PHP

<?php
/**
* 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
*/
namespace App\Utils\Traits;
use App\Jobs\Util\UploadFile;
use App\Models\Account;
use App\Models\Company;
trait SavesDocuments
{
public function saveDocuments($document_array, $entity)
{
if ($entity instanceof Company) {
$account = $entity->account;
$company = $entity;
} else {
$account = $entity->company->account;
$company = $entity->company;
}
if (!$account->hasFeature(Account::FEATURE_DOCUMENTS)) {
return false;
}
foreach ($document_array as $document) {
$document = UploadFile::dispatchNow(
$document,
UploadFile::DOCUMENT,
$entity->user,
$entity->company,
$entity
);
}
}
}