mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
commit
bcab38b364
@ -5,11 +5,13 @@ namespace App\Traits;
|
|||||||
use App\Models\AccountGateway;
|
use App\Models\AccountGateway;
|
||||||
use App\Models\AccountGatewaySettings;
|
use App\Models\AccountGatewaySettings;
|
||||||
use App\Models\AccountGatewayToken;
|
use App\Models\AccountGatewayToken;
|
||||||
|
use App\Models\AccountToken;
|
||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
use App\Models\ExpenseCategory;
|
use App\Models\ExpenseCategory;
|
||||||
|
use App\Models\Invitation;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentMethod;
|
use App\Models\PaymentMethod;
|
||||||
@ -28,8 +30,24 @@ trait GenerateMigrationResources
|
|||||||
{
|
{
|
||||||
protected $account;
|
protected $account;
|
||||||
|
|
||||||
|
protected $token;
|
||||||
|
|
||||||
protected function getAccount()
|
protected function getAccount()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if($this->account->account_tokens()->exists()){
|
||||||
|
$this->token = $this->account->account_tokens->first()->token;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
$mtoken = AccountToken::createNew();
|
||||||
|
$mtoken->name = 'Migration Token';
|
||||||
|
$mtoken->token = strtolower(str_random(RANDOM_KEY_LENGTH));
|
||||||
|
$mtoken->save();
|
||||||
|
|
||||||
|
$this->token = $mtoken->token;
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'plan' => $this->account->company->plan,
|
'plan' => $this->account->company->plan,
|
||||||
'plan_term' =>$this->account->company->plan_term,
|
'plan_term' =>$this->account->company->plan_term,
|
||||||
@ -45,11 +63,13 @@ trait GenerateMigrationResources
|
|||||||
'utm_campaign' =>$this->account->company->utm_campaign,
|
'utm_campaign' =>$this->account->company->utm_campaign,
|
||||||
'utm_term' =>$this->account->company->utm_term,
|
'utm_term' =>$this->account->company->utm_term,
|
||||||
'utm_content' =>$this->account->company->utm_content,
|
'utm_content' =>$this->account->company->utm_content,
|
||||||
|
'token' => $this->token,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCompany()
|
protected function getCompany()
|
||||||
{
|
{
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'referral_code' => $this->account->referral_code ?: '',
|
'referral_code' => $this->account->referral_code ?: '',
|
||||||
'account_id' => $this->account->id,
|
'account_id' => $this->account->id,
|
||||||
@ -883,7 +903,7 @@ trait GenerateMigrationResources
|
|||||||
'created_at' => $quote->created_at ? Carbon::parse($quote->created_at)->toDateString() : null,
|
'created_at' => $quote->created_at ? Carbon::parse($quote->created_at)->toDateString() : null,
|
||||||
'updated_at' => $quote->updated_at ? Carbon::parse($quote->updated_at)->toDateString() : null,
|
'updated_at' => $quote->updated_at ? Carbon::parse($quote->updated_at)->toDateString() : null,
|
||||||
'deleted_at' => $quote->deleted_at ? Carbon::parse($quote->deleted_at)->toDateString() : null,
|
'deleted_at' => $quote->deleted_at ? Carbon::parse($quote->deleted_at)->toDateString() : null,
|
||||||
//'invitations' => $this->getResourceInvitations($quote->invitations, 'quote_id'),
|
'invitations' => $this->getResourceInvitations($quote->invitations, 'quote_id'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,6 +1101,7 @@ trait GenerateMigrationResources
|
|||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
foreach ($documents as $document) {
|
foreach ($documents as $document) {
|
||||||
|
|
||||||
$transformed[] = [
|
$transformed[] = [
|
||||||
'id' => $document->id,
|
'id' => $document->id,
|
||||||
'user_id' => $document->user_id,
|
'user_id' => $document->user_id,
|
||||||
@ -1098,7 +1119,7 @@ trait GenerateMigrationResources
|
|||||||
'height' => $document->height,
|
'height' => $document->height,
|
||||||
'created_at' => $document->created_at ? Carbon::parse($document->created_at)->toDateString() : null,
|
'created_at' => $document->created_at ? Carbon::parse($document->created_at)->toDateString() : null,
|
||||||
'updated_at' => $document->updated_at ? Carbon::parse($document->updated_at)->toDateString() : null,
|
'updated_at' => $document->updated_at ? Carbon::parse($document->updated_at)->toDateString() : null,
|
||||||
'url' => $document->getUrl(),
|
'url' => url("/api/v1/documents/{$document->public_id}"),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user