mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for preview controller (#3486)
* fixes for user model * Remove stale css * Working on previewing designs * Fixes for design previews * fixes for preview controller * Fixes for setting company on login * fixes for preview
This commit is contained in:
parent
a151789d9c
commit
93056ea815
@ -202,6 +202,9 @@ class MigrationController extends BaseController
|
|||||||
if (app()->environment() == 'testing') return;
|
if (app()->environment() == 'testing') return;
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
\Log::error($user);
|
||||||
|
\Log::error($company);
|
||||||
|
\Log::error("starting migration");
|
||||||
|
|
||||||
StartMigration::dispatch($migration_file, $user, $company);
|
StartMigration::dispatch($migration_file, $user, $company);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class PreviewController extends BaseController
|
|||||||
request()->has('body'))
|
request()->has('body'))
|
||||||
{
|
{
|
||||||
|
|
||||||
$design_object = json_decode(json_encode(request()->input('body')));
|
$design_object = json_decode(json_encode(request()->input('design')));
|
||||||
|
|
||||||
if(!is_object($design_object))
|
if(!is_object($design_object))
|
||||||
return response()->json(['message' => 'Invalid custom design object'], 400);
|
return response()->json(['message' => 'Invalid custom design object'], 400);
|
||||||
@ -151,7 +151,7 @@ class PreviewController extends BaseController
|
|||||||
$invoice->setRelation('company', auth()->user()->company());
|
$invoice->setRelation('company', auth()->user()->company());
|
||||||
$invoice->load('client');
|
$invoice->load('client');
|
||||||
|
|
||||||
$design_object = json_decode(json_encode(request()->input('body')));
|
$design_object = json_decode(json_encode(request()->input('design')));
|
||||||
|
|
||||||
if(!is_object($design_object))
|
if(!is_object($design_object))
|
||||||
return response()->json(['message' => 'Invalid custom design object'], 400);
|
return response()->json(['message' => 'Invalid custom design object'], 400);
|
||||||
|
@ -129,7 +129,7 @@ class Import implements ShouldQueue
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
foreach ($this->data as $key => $resource) {
|
foreach ($this->data as $key => $resource) {
|
||||||
|
\Log::error("importing {$key}");
|
||||||
if (!in_array($key, $this->available_imports)) {
|
if (!in_array($key, $this->available_imports)) {
|
||||||
throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ class StartMigration implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
\Log::error("start handle");
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
auth()->login($this->user, false);
|
auth()->login($this->user, false);
|
||||||
@ -85,6 +86,8 @@ class StartMigration implements ShouldQueue
|
|||||||
|
|
||||||
if (app()->environment() !== 'production') info($e->getMessage());
|
if (app()->environment() !== 'production') info($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\Log::error("stop handle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -94,6 +97,9 @@ class StartMigration implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function start(string $filename): void
|
public function start(string $filename): void
|
||||||
{
|
{
|
||||||
|
|
||||||
|
\Log::error("start start");
|
||||||
|
|
||||||
$file = storage_path("migrations/$filename/migration.json");
|
$file = storage_path("migrations/$filename/migration.json");
|
||||||
|
|
||||||
if (!file_exists($file))
|
if (!file_exists($file))
|
||||||
@ -105,5 +111,8 @@ class StartMigration implements ShouldQueue
|
|||||||
|
|
||||||
$data = json_decode($file, 1);
|
$data = json_decode($file, 1);
|
||||||
Import::dispatchNow($data, $this->company, $this->user);
|
Import::dispatchNow($data, $this->company, $this->user);
|
||||||
|
|
||||||
|
|
||||||
|
\Log::error("start stop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
*/
|
*/
|
||||||
public function setCompany($company)
|
public function setCompany($company)
|
||||||
{
|
{
|
||||||
|
config(['ninja.company_id' => $company->id]);
|
||||||
|
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,8 +1332,8 @@ class CreateUsersTable extends Migration
|
|||||||
$t->timestamps(6);
|
$t->timestamps(6);
|
||||||
$t->softDeletes();
|
$t->softDeletes();
|
||||||
|
|
||||||
|
$t->foreign('company_id')->references('id')->on('companies')->onDelete('cascade')->onUpdate('cascade');
|
||||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
|
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
|
||||||
$t->foreign('company_id')->references('id')->on('companies')->onUpdate('cascade');
|
|
||||||
|
|
||||||
$t->unique(['company_id', 'name']);
|
$t->unique(['company_id', 'name']);
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,8 @@ class PreviewTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'entity' => 'invoice',
|
'entity' => 'invoice',
|
||||||
'entity_id' => $this->invoice->hashed_id,
|
'entity_id' => $this->invoice->hashed_id,
|
||||||
'body' => $design,
|
'design' => $design,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class PreviewTest extends TestCase
|
|||||||
$design = Design::find(3);
|
$design = Design::find(3);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'body' => $design,
|
'design' => $design,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user