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

Fixes for preview

This commit is contained in:
David Bomba 2021-08-05 21:45:54 +10:00
parent 2f970a0a39
commit 435a0ffc23

View File

@ -171,6 +171,8 @@ class PreviewController extends BaseController
{
MultiDB::setDb(auth()->user()->company()->db);
info("preview db = ".auth()->user()->company()->db);
if($request->input('entity') == 'invoice'){
$repo = new InvoiceRepository();
$factory = InvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id);
@ -200,13 +202,15 @@ class PreviewController extends BaseController
if($request->has('entity_id')){
// $entity_obj = $class::on(auth()->user()->company()->db)
// ->withTrashed()
// ->where('id', $this->decodePrimaryKey($request->input('entity_id')))
// ->where('company_id', auth()->user()->company()->id)
// ->first();
info("trying to find entity id = " . $this->decodePrimaryKey($request->input('entity_id')));
$entity_obj = $repo->save($request->all(), $factory);
$entity_obj = $class::on(auth()->user()->company()->db)
->withTrashed()
->where('id', $this->decodePrimaryKey($request->input('entity_id')))
->where('company_id', auth()->user()->company()->id)
->first();
$entity_obj = $repo->save($request->all(), $entity_obj);
}
else {