diff --git a/app/Livewire/Datatable/BrandsTable.php b/app/Livewire/Datatable/BrandsTable.php index dd7966e..c78c852 100644 --- a/app/Livewire/Datatable/BrandsTable.php +++ b/app/Livewire/Datatable/BrandsTable.php @@ -5,13 +5,15 @@ use App\Models\Brand; use App\Traits\Datatable\WithConfiguration; use App\Traits\Datatable\WithPrependColumn; +use App\Traits\WithMediaHandler; use Illuminate\Database\Eloquent\Builder; use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Views\Column; +use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn; class BrandsTable extends DataTableComponent { - use WithConfiguration, WithPrependColumn; + use WithConfiguration, WithMediaHandler, WithPrependColumn; protected $model = Brand::class; @@ -20,6 +22,13 @@ public function columns(): array return [ Column::make('Nama', 'name')->searchable(), + ImageColumn::make('Image') + ->location(fn ($row) => optional($row->getMedia('image')->first())->getUrl() ?? asset('assets/images/logo.png')) + ->attributes(fn ($row) => [ + 'style' => 'width: 50px; height: 50px;', + 'alt' => $row->name, + ]), + Column::make('Aksi') ->label(function ($row) { $actions = '';