Skip to content

Commit

Permalink
feat: history of the compound is now available in the compound detail…
Browse files Browse the repository at this point in the history
…s page
  • Loading branch information
sriramkanakam87 committed Aug 30, 2024
1 parent 76bb88d commit bc26426
Show file tree
Hide file tree
Showing 5 changed files with 599 additions and 193 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/OrganismDedupeOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public function handle()
$removableOrganism->auditDetach('molecules', $moleculeIds);
$selectedOrganism->auditSyncWithoutDetaching('molecules', $moleculeIds);

$removableOrganism->molecule_count = $removableOrganism->molecules()->count();
$removableOrganism->delete();
$selectedOrganism->refresh();
$selectedOrganism->molecule_count = $selectedOrganism->molecules()->count();
$selectedOrganism->save();

Expand Down
42 changes: 42 additions & 0 deletions app/Livewire/MoleculeHistoryTimeline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Livewire;

use Livewire\Attributes\Computed;
use Livewire\Component;
use App\Models\Molecule;
use App\Models\User;

class MoleculeHistoryTimeline extends Component
{

public $mol = null;
public $audit_data = [];

// #[Computed]
public function getHistory()
{
$audit_data = [];
$molecule = Molecule::find($this->mol->id);
foreach ($molecule->audits as $index => $audit) {
// dd($audit->getMetadata());
// dd(array_keys($audit->getModified())[0]);
$audit_data[$index]['user_name'] = $audit->getMetadata()['user_name'];
$audit_data[$index]['event'] = $audit->getMetadata()['audit_event'];
$audit_data[$index]['created_at'] = date('Y/m/d',strtotime($audit->getMetadata()['audit_created_at']));
foreach ($audit->getModified() as $key => $value) {
$audit_data[$index]['affected_column'] = $key;
$audit_data[$index]['old_value'] = $value['old'];
$audit_data[$index]['new_value'] = $value['new'];
}
}
$this->audit_data = $audit_data;
}

public function render()
{
return view('livewire.molecule-history-timeline')->with([
'audit_data' => $this->audit_data,
]);
}
}
Loading

0 comments on commit bc26426

Please sign in to comment.