LAR_Maintenance/app/Livewire/MaintenanceHistory/DataTable.php
2024-07-31 18:45:14 +02:00

41 lines
985 B
PHP

<?php
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',
'start_at' => 'start_at',
'finished_at' => 'finished_at',
];
}
public function remove($maintenancehistory_id)
{
MaintenanceHistory::find($maintenancehistory_id)->delete();
}
public function renderColumnMaintenanceName($val, $row)
{
$ret = '<a href="' . route('maintenance.planned.detail', $row['id']) . '">' . e($val) . '</a>';
return $ret;
}
}