60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Datatable;
|
|
|
|
use App\Models\Membership;
|
|
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 MembershipsTable extends DataTableComponent
|
|
{
|
|
use WithAppendColumn, WithConfiguration, WithPrependColumn;
|
|
|
|
protected $model = Membership::class;
|
|
|
|
public function columns(): array
|
|
{
|
|
return [
|
|
Column::make('Nama', 'name')->searchable(),
|
|
|
|
Column::make('Min. Pembelian', 'min_purchase')
|
|
->format(fn ($value) => currency($value, 'Rp'))
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
Column::make('Diskon', 'discount_percentage')
|
|
->format(fn ($value) => percentage($value))
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
Column::make('Aksi')
|
|
->label(function ($row) {
|
|
$actions = '';
|
|
|
|
$actions .= view('components.datatables.edit-modal', [
|
|
'id' => $row->id,
|
|
'method' => 'update',
|
|
'modalTitle' => 'Ubah Membership',
|
|
])->render();
|
|
|
|
$actions .= view('components.datatables.delete', [
|
|
'id' => $row->id,
|
|
'deleteRoute' => route('studio.loyalty.membership.delete', $row->id),
|
|
])->render();
|
|
|
|
return $actions;
|
|
})
|
|
->html(),
|
|
];
|
|
}
|
|
|
|
public function builder(): Builder
|
|
{
|
|
return Membership::select('id', 'name', 'discount_percentage', 'min_purchase');
|
|
}
|
|
}
|