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',
|
2024-08-08 08:33:21 +00:00
|
|
|
'schedule' => 'schedule/offset',
|
2024-07-30 16:13:21 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-08-08 08:33: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]);
|
|
|
|
}
|
|
|
|
}
|