mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Export 'documents' (#3343)
* Export 'documents' * Export 'invoice_id' & 'expense_id' with documents * Code cleanup
This commit is contained in:
parent
2a8d2c7f5e
commit
9085a27361
@ -9,10 +9,9 @@ use App\Models\Payment;
|
|||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\TaxRate;
|
use App\Models\TaxRate;
|
||||||
use App\Libraries\Utils;
|
use App\Libraries\Utils;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use App\Http\Controllers\BaseController;
|
use App\Http\Controllers\BaseController;
|
||||||
|
use App\Models\Document;
|
||||||
|
|
||||||
class StepsController extends BaseController
|
class StepsController extends BaseController
|
||||||
{
|
{
|
||||||
@ -65,6 +64,7 @@ class StepsController extends BaseController
|
|||||||
'quotes' => $this->getQuotes(),
|
'quotes' => $this->getQuotes(),
|
||||||
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
'payments' => array_merge($this->getPayments(), $this->getCredits()),
|
||||||
'credits' => $this->getCreditsNotes(),
|
'credits' => $this->getCreditsNotes(),
|
||||||
|
'documents' => $this->getDocuments(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$file = storage_path("{$fileName}.zip");
|
$file = storage_path("{$fileName}.zip");
|
||||||
@ -609,4 +609,37 @@ class StepsController extends BaseController
|
|||||||
|
|
||||||
return $transformed;
|
return $transformed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function getDocuments()
|
||||||
|
{
|
||||||
|
$documents = Document::where('account_id', $this->account->id)->get();
|
||||||
|
|
||||||
|
$transformed = [];
|
||||||
|
|
||||||
|
foreach ($documents as $document) {
|
||||||
|
$transformed[] = [
|
||||||
|
'id' => $document->id,
|
||||||
|
'user_id' => $document->user_id,
|
||||||
|
'company_id' => $this->account->id,
|
||||||
|
'invoice_id' => $document->invoice_id,
|
||||||
|
'expense_id' => $document->expense_id,
|
||||||
|
'path' => $document->path,
|
||||||
|
'preview' => $document->preview,
|
||||||
|
'name' => $document->name,
|
||||||
|
'type' => $document->type,
|
||||||
|
'disk' => $document->disk,
|
||||||
|
'hash' => $document->hash,
|
||||||
|
'size' => $document->size,
|
||||||
|
'width' => $document->width,
|
||||||
|
'height' => $document->height,
|
||||||
|
'created_at' => $document->created_at ? $document->created_at->toDateString() : null,
|
||||||
|
'updated_at' => $document->updated_at ? $document->updated_at->toDateString() : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $transformed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user