LAR_Maintenance/app/Livewire/Maintenance/DataTable.php

66 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2024-07-30 16:13:21 +00:00
<?php
namespace App\Livewire\Maintenance;
use App\Models\Maintenance;
use SteelAnts\DataTable\Livewire\DataTableComponent;
use Illuminate\Database\Eloquent\Builder;
class DataTable extends DataTableComponent
{
public $listeners = [
'maintenanceAdded' => '$refresh',
'closeModal' => '$refresh',
];
public function query(): Builder
{
return Maintenance::query();
}
public function headers(): array
{
return [
'name' => 'name',
'description' => 'description',
'schedule' => 'schedule/offset',
2024-07-30 16:13:21 +00:00
];
}
public function renderColumnSchedule($value, $row)
{
return e(!empty($value) ? $value : $row['blocking_maintenance_offset']);
}
public function renderColumnDescription($value, $row)
{
return e(!empty($value) ? mb_strimwidth(strip_tags($value), 0, 50, "...") : "");
}
2024-07-30 16:13:21 +00:00
public function remove($maintenance_id){
Maintenance::find($maintenance_id)->delete();
}
public function actions($item)
{
return [
[
'type' => "livewire",
'action' => "edit",
'text' => "edit",
'parameters' => $item['id']
],
[
'type' => "livewire",
'action' => "remove",
'text' => "remove",
'parameters' => $item['id']
]
];
}
public function edit($maintenance_id)
{
$this->dispatch('openModal', 'maintenance.form', __('boilerplate::maintenances.edit'), ['model' => $maintenance_id]);
}
}