1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Migration for projects

This commit is contained in:
David Bomba 2020-10-30 22:53:50 +11:00
parent aff75e1d59
commit 38c017fdf8
2 changed files with 37 additions and 0 deletions

View File

@ -252,6 +252,7 @@ class StepsController extends BaseController
'client_gateway_tokens' => $this->getClientGatewayTokens(),
'expense_categories' => $this->getExpenseCategories(),
'task_statuses' => $this->getTaskStatuses(),
'projects' => $this->getProjects(),
'expenses' => $this->getExpenses(),
'tasks' => $this->getTasks(),
];

View File

@ -15,6 +15,7 @@ use App\Models\Payment;
use App\Models\PaymentMethod;
use App\Models\PaymentTerm;
use App\Models\Product;
use App\Models\Project;
use App\Models\Task;
use App\Models\TaskStatus;
use App\Models\TaxRate;
@ -1187,6 +1188,41 @@ trait GenerateMigrationResources
return $transformed;
}
private function getProjects()
{
$projects = Project::where('account_id', $this->account->id)
->withTrashed()
->get();
$transformed = [];
foreach ($projects as $project)
{
$transformed[] = [
'id' => $project->id,
'company_id' => $this->account->id,
'client_id' => $project->client_id,
'custom_value1' => $project->custom_value1,
'custom_value2' => $project->custom_value2,
'custom_value3' => $project->custom_value3,
'custom_value4' => $project->custom_value4,
'budgeted_hours' => $project->budgeted_hours,
'due_date' => $project->due_date,
'name' => $project->name,
'private_notes' => $project->private_notes,
'public_notes' => '',
'task_rate' => $project->task_rate,
'user_id' => $project->user_id,
'is_deleted' => $project->is_deleted,
'created_at' => $project->created_at ? $project->created_at->toDateString() : null,
'updated_at' => $project->updated_at ? $project->updated_at->toDateString() : null,
'deleted_at' => $project->deleted_at ? $project->deleted_at->toDateString() : null,
];
}
return $transformed;
}
private function convertMeta($payment_method)
{
$expiry = explode('-', $payment_method->expiration);