feat(brand)": menampilkan gambar di tabel
This commit is contained in:
parent
49d411bf18
commit
7ecf7c5e0d
@ -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 = '';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user