54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
|
<?php
|
||
|
namespace App\Livewire\Host;
|
||
|
|
||
|
use App\Models\Host;
|
||
|
use SteelAnts\DataTable\Livewire\DataTableComponent;
|
||
|
use Illuminate\Database\Eloquent\Builder;
|
||
|
|
||
|
class DataTable extends DataTableComponent
|
||
|
{
|
||
|
public $listeners = [
|
||
|
'hostAdded' => '$refresh',
|
||
|
'closeModal' => '$refresh',
|
||
|
];
|
||
|
|
||
|
public function query(): Builder
|
||
|
{
|
||
|
return Host::query();
|
||
|
}
|
||
|
|
||
|
public function headers(): array
|
||
|
{
|
||
|
return [
|
||
|
'hostname' => 'hostname',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function remove($host_id){
|
||
|
Host::find($host_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($host_id)
|
||
|
{
|
||
|
$this->dispatch('openModal', 'host.form', __('boilerplate::host.edit'), ['model' => $host_id]);
|
||
|
}
|
||
|
}
|