2024-07-31 15:04:33 +00:00
|
|
|
<?php
|
2024-07-31 16:45:14 +00:00
|
|
|
|
2024-07-31 15:04:33 +00:00
|
|
|
namespace App\Livewire\MaintenanceHistory;
|
|
|
|
|
|
|
|
use App\Models\MaintenanceHistory;
|
|
|
|
use SteelAnts\DataTable\Livewire\DataTableComponent;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
|
|
|
|
class DataTable extends DataTableComponent
|
|
|
|
{
|
|
|
|
public $listeners = [
|
|
|
|
'maintenanceHistoryAdded' => '$refresh',
|
|
|
|
'closeModal' => '$refresh',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function query(): Builder
|
|
|
|
{
|
|
|
|
return MaintenanceHistory::query();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function headers(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'maintenance.name' => 'maintenance.name',
|
2024-07-31 16:45:14 +00:00
|
|
|
'start_at' => 'start_at',
|
|
|
|
'finished_at' => 'finished_at',
|
2024-07-31 15:04:33 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-07-31 16:45:14 +00:00
|
|
|
public function remove($maintenancehistory_id)
|
|
|
|
{
|
2024-07-31 15:04:33 +00:00
|
|
|
MaintenanceHistory::find($maintenancehistory_id)->delete();
|
|
|
|
}
|
2024-07-31 16:45:14 +00:00
|
|
|
|
|
|
|
public function renderColumnMaintenanceName($val, $row)
|
|
|
|
{
|
|
|
|
$ret = '<a href="' . route('maintenance.planned.detail', $row['id']) . '">' . e($val) . '</a>';
|
|
|
|
return $ret;
|
|
|
|
}
|
2024-08-06 14:57:48 +00:00
|
|
|
|
|
|
|
public function actions($item)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'type' => "livewire",
|
|
|
|
'action' => "remove",
|
|
|
|
'text' => "remove",
|
|
|
|
'parameters' => $item['id']
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
2024-07-31 15:04:33 +00:00
|
|
|
}
|