LAR_Maintenance/app/Livewire/Task/DataTable.php
2024-08-06 11:02:45 +02:00

55 lines
1.2 KiB
PHP

<?php
namespace App\Livewire\Task;
use App\Models\Task;
use SteelAnts\DataTable\Livewire\DataTableComponent;
use Illuminate\Database\Eloquent\Builder;
class DataTable extends DataTableComponent
{
public $listeners = [
'taskAdded' => '$refresh',
'closeModal' => '$refresh',
];
public function query(): Builder
{
return Task::query();
}
public function headers(): array
{
return [
'name' => 'name',
'description' => 'description',
];
}
public function remove($task_id){
Task::find($task_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($task_id)
{
$this->dispatch('openModal', 'task.form', __('boilerplate::task.edit'), ['model' => $task_id]);
}
}