LAR_Maintenance/app/Livewire/MaintenanceTask/DataTable.php

55 lines
1.3 KiB
PHP
Raw Normal View History

2024-08-06 06:31:51 +00:00
<?php
namespace App\Livewire\MaintenanceTask;
use App\Models\MaintenanceTask;
use SteelAnts\DataTable\Livewire\DataTableComponent;
use Illuminate\Database\Eloquent\Builder;
class DataTable extends DataTableComponent
{
public $listeners = [
'maintenancetaskAdded' => '$refresh',
'closeModal' => '$refresh',
];
public function query(): Builder
{
return MaintenanceTask::query();
}
public function headers(): array
{
return [
'name' => 'name',
'description' => 'description',
];
}
public function remove($maintenancetask_id){
MaintenanceTask::find($maintenancetask_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($maintenancetask_id)
{
$this->dispatch('openModal', 'maintenance-task.form', __('boilerplate::maintenance-task.edit'), ['model' => $maintenancetask_id]);
}
}