added datagrid table
This commit is contained in:
@@ -10,31 +10,44 @@ class InvoiceDataTable extends Component
|
||||
|
||||
public $invoiceData = [];
|
||||
|
||||
public string $invoiceNumber = '';
|
||||
|
||||
public bool $hasSearched = false;
|
||||
|
||||
protected $listeners = ['refreshInvoiceData' => 'loadData'];
|
||||
|
||||
public function mount()
|
||||
public function loadData($invoiceNumber)
|
||||
{
|
||||
$this->loadData();
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->hasSearched = true;
|
||||
|
||||
}
|
||||
$this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
'serial_number' => $record->serial_number,
|
||||
'motor_scanned_status' => $record->motor_scanned_status,
|
||||
'pump_scanned_status' => $record->pump_scanned_status,
|
||||
'capacitor_scanned_status' => $record->capacitor_scanned_status,
|
||||
'scanned_status_set' => $record->scanned_status_set,
|
||||
'panel_box_supplier' => $record->panel_box_supplier,
|
||||
'panel_box_serial_number' => $record->panel_box_serial_number,
|
||||
'scanned_status' => $record->scanned_status,
|
||||
];
|
||||
})
|
||||
|
||||
public function loadData()
|
||||
{
|
||||
$this->invoiceData = InvoiceValidation::all()->toArray();
|
||||
->toArray();
|
||||
|
||||
//Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
$stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
$row['code'] = $stickerMaster?->item?->code ?? 'N/A';
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
// Always fetch fresh data when Livewire re-renders (like via polling)
|
||||
$invoiceData = InvoiceValidation::latest()->get();
|
||||
|
||||
return view('livewire.invoice-data-table', [
|
||||
'invoiceData' => $invoiceData,
|
||||
]);
|
||||
// return view('livewire.invoice-data-table', [
|
||||
// 'invoiceData' => $this->invoiceData, // <--- this is important
|
||||
// ]);
|
||||
return view('livewire.invoice-data-table');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user