47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\View\Components;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\View\Component;
|
|
|
|
class DataTable extends Component
|
|
{
|
|
public string $id;
|
|
public string $ajax;
|
|
public array $columns;
|
|
public ?string $bulkDeleteUrl;
|
|
|
|
public function __construct(
|
|
string $id,
|
|
string $ajax,
|
|
array $columns,
|
|
?string $bulkDeleteUrl = null
|
|
) {
|
|
$this->id = $id;
|
|
$this->ajax = $ajax;
|
|
$this->columns = $columns;
|
|
$this->bulkDeleteUrl = $bulkDeleteUrl;
|
|
|
|
if ($this->bulkDeleteUrl) {
|
|
array_unshift($this->columns, [
|
|
'key' => 'checkbox',
|
|
'label' => '<div class="form-check d-flex align-items-center justify-content-center"><input class="form-check-input" type="checkbox" id="dt-master-checkbox"></div>',
|
|
'orderable' => false,
|
|
'searchable' => false,
|
|
'className' => 'text-center align-middle',
|
|
'width' => '30px'
|
|
]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represent the component.
|
|
*/
|
|
public function render(): View|Closure|string
|
|
{
|
|
return view('components.data-table');
|
|
}
|
|
}
|