LAR_Maintenance/app/Livewire/Maintenance/DataTable.php
JonatanRek 571df9a0a4 Fixes
2024-07-30 18:13:21 +02:00

56 lines
1.3 KiB
PHP

<?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',
];
}
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]);
}
}