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\Models\Brand;
|
||||||
use App\Traits\Datatable\WithConfiguration;
|
use App\Traits\Datatable\WithConfiguration;
|
||||||
use App\Traits\Datatable\WithPrependColumn;
|
use App\Traits\Datatable\WithPrependColumn;
|
||||||
|
use App\Traits\WithMediaHandler;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Column;
|
use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||||
|
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
|
||||||
|
|
||||||
class BrandsTable extends DataTableComponent
|
class BrandsTable extends DataTableComponent
|
||||||
{
|
{
|
||||||
use WithConfiguration, WithPrependColumn;
|
use WithConfiguration, WithMediaHandler, WithPrependColumn;
|
||||||
|
|
||||||
protected $model = Brand::class;
|
protected $model = Brand::class;
|
||||||
|
|
||||||
@ -20,6 +22,13 @@ public function columns(): array
|
|||||||
return [
|
return [
|
||||||
Column::make('Nama', 'name')->searchable(),
|
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')
|
Column::make('Aksi')
|
||||||
->label(function ($row) {
|
->label(function ($row) {
|
||||||
$actions = '';
|
$actions = '';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user