58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Datatable\Studio\Loyalty;
|
|
|
|
use App\Models\Tier;
|
|
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 TiersTable extends DataTableComponent
|
|
{
|
|
use WithAppendColumn, WithConfiguration, WithPrependColumn;
|
|
|
|
protected $model = Tier::class;
|
|
|
|
public function columns(): array
|
|
{
|
|
return [
|
|
Column::make('Nama', 'name')->searchable(),
|
|
|
|
Column::make('Min. Poin', 'min_points')->searchable()->sortable(),
|
|
|
|
Column::make('Maks. Poin', 'max_points')->searchable()->sortable(),
|
|
|
|
Column::make('Aksi')
|
|
->label(function ($row) {
|
|
$actions = '';
|
|
|
|
if (auth()->user()->can('update tier')) {
|
|
$actions .= view('components.datatables.edit-modal', [
|
|
'id' => $row->id,
|
|
'method' => 'update',
|
|
'modalTitle' => 'Ubah Tier',
|
|
])->render();
|
|
}
|
|
|
|
if (auth()->user()->can('delete tier')) {
|
|
$actions .= view('components.datatables.delete', [
|
|
'id' => $row->id,
|
|
'deleteRoute' => route('studio.loyalty.tier.delete', $row->id),
|
|
])->render();
|
|
}
|
|
|
|
return $actions;
|
|
})
|
|
->html(),
|
|
];
|
|
}
|
|
|
|
public function builder(): Builder
|
|
{
|
|
return Tier::select('id', 'name', 'min_points', 'max_points');
|
|
}
|
|
}
|