64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Datatable\Studio\Master;
|
|
|
|
use App\Models\Formula;
|
|
use App\Traits\Datatable\WithAppendColumn;
|
|
use App\Traits\Datatable\WithConfiguration;
|
|
use App\Traits\Datatable\WithPrependColumn;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
|
use Rappasoft\LaravelLivewireTables\Views\Column;
|
|
|
|
class FormulasTable extends DataTableComponent
|
|
{
|
|
use WithAppendColumn, WithConfiguration, WithPrependColumn;
|
|
|
|
protected $model = Formula::class;
|
|
|
|
public function columns(): array
|
|
{
|
|
return [
|
|
Column::make('Kualitas', 'quality')->searchable(),
|
|
|
|
Column::make('Ukuran', 'size')
|
|
->format(fn ($row, $column) => $row.' ml')
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
Column::make('Volume', 'volume')
|
|
->format(fn ($row, $column) => $row.' ml')
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
Column::make('Aksi')
|
|
->label(function ($row) {
|
|
$actions = '';
|
|
|
|
if (auth()->user()->can('update formula')) {
|
|
$actions .= view('components.datatables.edit-modal', [
|
|
'id' => $row->hash,
|
|
'method' => 'update',
|
|
'modalTitle' => 'Ubah Rumus',
|
|
])->render();
|
|
}
|
|
|
|
if (auth()->user()->can('delete formula')) {
|
|
$actions .= view('components.datatables.delete', [
|
|
'id' => $row->hash,
|
|
'deleteRoute' => route('studio.master.formula.delete', $row->hash),
|
|
])->render();
|
|
}
|
|
|
|
return $actions;
|
|
})
|
|
->html(),
|
|
];
|
|
}
|
|
|
|
public function builder(): Builder
|
|
{
|
|
return Formula::select('id', 'quality', 'size', 'volume');
|
|
}
|
|
}
|