<?php
namespace App\Http\Livewire;
use App\Models\Machine;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Livewire\Component;
class ListMachines extends Component implements HasTable
{
use InteractsWithTable;
protected function getTableQuery(): Builder|Relation
{
return Machine::query()->with(['customer', 'modelname']);
}
protected function getTableColumns(): array
{
return [
TextColumn::make('id')->sortable(),
TextColumn::make('inventory_number')->sortable()->searchable(),
TextColumn::make('modelname.name')->sortable()->searchable(),
TextColumn::make('installation_date')->sortable(),
TextColumn::make('customer_name')->sortable()->searchable(),
TextColumn::make('location_address')->sortable(),
IconColumn::make('service_contract')->boolean()
->trueColor('green')
->falseColor('red'),
TextColumn::make('notes')->searchable()
];
}
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
{
return view('livewire.list-machines');
}
}