Changes
This commit is contained in:
@@ -21,7 +21,11 @@ class ImportController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$paginator = Import::query()
|
||||
->with(['client:id,uuid', 'template:id,name'])
|
||||
->with([
|
||||
'client:id,uuid,person_id',
|
||||
'client.person:id,uuid,full_name',
|
||||
'template:id,name',
|
||||
])
|
||||
->orderByDesc('created_at')
|
||||
->paginate(15);
|
||||
|
||||
@@ -52,8 +56,15 @@ public function index(Request $request)
|
||||
'original_name' => $imp->original_name,
|
||||
'size' => $imp->size,
|
||||
'status' => $imp->status,
|
||||
'client' => $imp->client ? [ 'id' => $imp->client_id, 'uuid' => $imp->client->uuid ] : null,
|
||||
'template' => $imp->template ? [ 'id' => $imp->import_template_id, 'name' => $imp->template->name ] : null,
|
||||
'client' => $imp->client ? [
|
||||
'id' => $imp->client_id,
|
||||
'uuid' => $imp->client->uuid,
|
||||
'person' => $imp->client->person ? [
|
||||
'uuid' => $imp->client->person->uuid,
|
||||
'full_name' => $imp->client->person->full_name,
|
||||
] : null,
|
||||
] : null,
|
||||
'template' => $imp->template ? [ 'id' => $imp->template->id, 'name' => $imp->template->name ] : null,
|
||||
];
|
||||
}, $imports['data']);
|
||||
|
||||
@@ -316,6 +327,7 @@ public function show(Import $import)
|
||||
$templates = ImportTemplate::query()
|
||||
->leftJoin('clients', 'clients.id', '=', 'import_templates.client_id')
|
||||
->where('import_templates.is_active', true)
|
||||
->where('import_templates.id', $import->import_template_id)
|
||||
->orderBy('import_templates.name')
|
||||
->get([
|
||||
'import_templates.id',
|
||||
@@ -324,18 +336,30 @@ public function show(Import $import)
|
||||
'import_templates.source_type',
|
||||
'import_templates.default_record_type',
|
||||
'import_templates.client_id',
|
||||
DB::raw('clients.uuid as client_uuid'),
|
||||
'clients.uuid as client_uuid',
|
||||
]);
|
||||
|
||||
|
||||
$clients = Client::query()
|
||||
->join('person', 'person.id', '=', 'clients.person_id')
|
||||
->orderBy('person.full_name')
|
||||
->where('clients.id', $import->client_id)
|
||||
->get([
|
||||
'clients.id',
|
||||
'clients.uuid',
|
||||
DB::raw('person.full_name as name'),
|
||||
'person.full_name as name'
|
||||
]);
|
||||
|
||||
// Import client
|
||||
$client = Client::query()
|
||||
->join('person', 'person.id', '=', 'clients.person_id')
|
||||
->where('clients.id', $import->client_id)
|
||||
->firstOrFail([
|
||||
'clients.uuid as uuid',
|
||||
'person.full_name as name',
|
||||
]);
|
||||
|
||||
|
||||
// Render a dedicated page to continue the import
|
||||
return Inertia::render('Imports/Import', [
|
||||
'import' => [
|
||||
@@ -344,15 +368,17 @@ public function show(Import $import)
|
||||
'status' => $import->status,
|
||||
'meta' => $import->meta,
|
||||
'client_id' => $import->client_id,
|
||||
'client_uuid' => optional($client)->uuid,
|
||||
'import_template_id' => $import->import_template_id,
|
||||
'total_rows' => $import->total_rows,
|
||||
'imported_rows' => $import->imported_rows,
|
||||
'invalid_rows' => $import->invalid_rows,
|
||||
'valid_rows' => $import->valid_rows,
|
||||
'finished_at' => $import->finished_at,
|
||||
'finished_at' => $import->finished_at
|
||||
],
|
||||
'templates' => $templates,
|
||||
'clients' => $clients,
|
||||
'client' => $client
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user