55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
|
<?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]);
|
||
|
}
|
||
|
}
|