Skip to content

Commit

Permalink
namespace fix, and remove prefix t_
Browse files Browse the repository at this point in the history
  • Loading branch information
damarteplok committed Jan 11, 2020
1 parent b92a3de commit be876ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Console/Commands/GenerateTableByProcessDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function handle()
$tableGenerateds = [];
foreach ($camundaForms as $camundaForm) {
//prefix t
$prefixName = 't_'.$camundaForm->form_name;
$prefixName = $camundaForm->form_name;
$tableGenerateds[$prefixName][] = [
'name' => $camundaForm->field_name,
'type' => $camundaForm->field_type,
Expand Down
8 changes: 4 additions & 4 deletions src/Services/FormAdapter/FormAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Laravolt\Workflow\Services\FormAdapter;

use App\Services\FormAdapter\Fields\StringAdapter;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Collection;
use Laravolt\Workflow\Services\FormAdapter\Fields\StringAdapter;

class FormAdapter
{
Expand Down Expand Up @@ -89,8 +89,8 @@ protected function transformFields($fields, $segment)
$definition = [];
foreach ($fields as $field) {
$type = Str::studly($field->field_type);

$adapter = "\\App\\Services\\FormAdapter\\Fields\\{$type}Adapter";
$adapter = "\\Laravolt\\Workflow\\Services\\FormAdapter\\Fields\\{$type}Adapter";
if (! class_exists($adapter)) {
$adapter = StringAdapter::class;
}
Expand Down
8 changes: 2 additions & 6 deletions src/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function startProcess(Module $module, array $data): ProcessInstance
// Flagnya ada di kolom camunda_form.type
foreach ($payload->toFormFields() as $form => $fields) {
$dbFields = $fields['fields'];

if ($fields['type'] == FormType::MAIN_FORM) {
$data = $dbFields + $additionalData;
$formId = $this->insertData($form, $data);
Expand All @@ -117,7 +117,6 @@ public function startProcess(Module $module, array $data): ProcessInstance
'task_name' => $module->startTaskName,
'process_definition_key' => $processDefinition->key,
'created_at' => now(),
'id_kantor' => auth()->user()->kantor->id,
'ref_id' => $payload->data['ref_id'] ?? request('ref_id'),
'traceable' => json_encode(collect($payload->data)->only(config('laravolt.workflow.traceable')) ?? []),
]);
Expand Down Expand Up @@ -262,7 +261,6 @@ public function submitTask(Module $module, string $taskId, array $data, bool $is
'status' => $isDraft ? TaskStatus::DRAFT : TaskStatus::UNASSIGNED,
'created_at' => now(),
'updated_at' => now(),
'id_kantor' => auth()->user()->kantor->id,
'ref_id' => $payload->data['ref_id']['ref_id'] ?? request('ref_id'),
]
);
Expand Down Expand Up @@ -417,11 +415,10 @@ protected function insertData(string $table, array $data)
$additionalData = [
'created_by' => auth()->id(),
'created_at' => now(),
'id_kantor' => auth()->user()->kantor->id,
];

[$mainTableData, $hasManyData] = $this->filterAndPartition($data, $table);

$id = DB::table($table)->insertGetId($mainTableData + $additionalData);

$this->saveHasMany($hasManyData, $additionalData, $table, $id);
Expand All @@ -434,7 +431,6 @@ protected function updateData($id, string $table, array $data)
$additionalData = [
'created_by' => auth()->id(),
'created_at' => now(),
'id_kantor' => auth()->user()->kantor->id,
];

[$mainTableData, $hasManyData] = $this->filterAndPartition($data, $table);
Expand Down

0 comments on commit be876ce

Please sign in to comment.