1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Utils/Traits/SavesDocuments.php

47 lines
1.1 KiB
PHP
Raw Normal View History

<?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
{
2020-08-18 16:12:46 +02:00
public function saveDocuments($document_array, $entity, $is_public = false)
{
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,
2020-08-18 16:12:46 +02:00
$entity,
null,
$is_public
);
}
}
}