LAR_Maintenance/app/Livewire/Maintenance/DataTable.php

56 lines
1.3 KiB
PHP
Raw 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',
];
}
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]);
}
}