<?php

namespace App\Filament\Resources;

use App\Filament\Resources\ItemCharacteristicResource\Pages;
use App\Filament\Resources\ItemCharacteristicResource\RelationManagers;
use App\Models\Item;
use App\Models\ItemCharacteristic;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class ItemCharacteristicResource extends Resource
{
    protected static ?string $model = ItemCharacteristic::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    protected static ?string $navigationGroup = 'Customized Sticker Printing';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                 Forms\Components\Select::make('plant_id')
                    ->label('Plant')
                    ->reactive()
                    ->relationship('plant', 'name')
                    ->options(function (callable $get) {
                        $userHas = Filament::auth()->user()->plant_id;
                        return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
                    })
                    ->required(),
                Forms\Components\Select::make('item_id')
                    ->label('Item Code')
                    //->relationship('item', 'id')
                    ->reactive()
                    ->searchable()
                    ->options(function (callable $get) {
                        $plantId = $get('plant_id');
                        if (empty($plantId)) {
                            return [];
                        }
                        return Item::where('plant_id', $plantId)->pluck('code', 'id');
                    })
                    ->required(),
                Forms\Components\TextInput::make('class')
                    ->label('Class'),
                Forms\Components\TextInput::make('zz1_cn_bill_ord')
                    ->label('ZZ1 CN Bill Ord'),
                Forms\Components\TextInput::make('zmm_amps')
                    ->label('ZMM Amps'),
                Forms\Components\TextInput::make('zmm_brand')
                    ->label('ZMM Brand'),
                Forms\Components\TextInput::make('zmm_degreeofprotection')
                    ->label('ZMM Degree of Protection'),
                Forms\Components\TextInput::make('zmm_delivery')
                    ->label('ZMM Delivery'),
                Forms\Components\TextInput::make('zmm_dir_rot')
                    ->label('ZMM Direction Rotation'),
                Forms\Components\TextInput::make('zmm_discharge')
                    ->label('ZMM Discharge'),
                Forms\Components\TextInput::make('zmm_discharge_max')
                    ->label('ZMM Discharge Max'),
                Forms\Components\TextInput::make('zmm_discharge_min')
                    ->label('ZMM Discharge Min'),
                Forms\Components\TextInput::make('zmm_duty')
                    ->label('ZMM Duty'),
                Forms\Components\TextInput::make('zmm_eff_motor')
                    ->label('ZMM Eff Motor'),
                Forms\Components\TextInput::make('zmm_eff_pump')
                    ->label('ZMM Eff Pump'),
                Forms\Components\TextInput::make('zmm_frequency')
                    ->label('ZMM Frequency'),
                Forms\Components\TextInput::make('zmm_head')
                    ->label('ZMM Head'),
                Forms\Components\TextInput::make('zmm_heading')
                    ->label('ZMM Heading'),
                Forms\Components\TextInput::make('zmm_head_max')
                    ->label('ZMM Head Max'),
                Forms\Components\TextInput::make('zmm_head_minimum')
                    ->label('ZMM Head Minimum'),
                Forms\Components\TextInput::make('zmm_idx_eff_mtr')
                    ->label('ZMM Idx Eff Mtr'),
                Forms\Components\TextInput::make('zmm_idx_eff_pump')
                    ->label('ZMM Idx Eff Pump'),
                Forms\Components\TextInput::make('zmm_kvacode')
                    ->label('ZMM KVACode'),
                Forms\Components\TextInput::make('zmm_maxambtemp')
                    ->label('ZMM Max Amb Temp'),
                Forms\Components\TextInput::make('zmm_mincoolingflow')
                    ->label('ZMM Min Cooling Flow'),
                Forms\Components\TextInput::make('zmm_motorseries')
                    ->label('ZMM Motor Series'),
                Forms\Components\TextInput::make('zmm_motor_model')
                    ->label('ZMM Motor Model'),
                Forms\Components\TextInput::make('zmm_outlet')
                    ->label('ZMM Outlet'),
                Forms\Components\TextInput::make('zmm_phase')
                    ->label('ZMM Phase'),
                Forms\Components\TextInput::make('zmm_pressure')
                    ->label('ZMM Pressure'),
                Forms\Components\TextInput::make('zmm_pumpflowtype')
                    ->label('ZMM Pump Flow Type'),
                Forms\Components\TextInput::make('zmm_pumpseries')
                    ->label('ZMM Pump Series'),
                Forms\Components\TextInput::make('zmm_pump_model')
                    ->label('ZMM Pump Model'),
                Forms\Components\TextInput::make('zmm_ratedpower')
                    ->label('ZMM Rated Power'),
                Forms\Components\TextInput::make('zmm_region')
                    ->label('ZMM Region'),
                Forms\Components\TextInput::make('zmm_servicefactor')
                    ->label('ZMM Service Factor'),
                Forms\Components\TextInput::make('zmm_servicefactormaximumamps')
                    ->label('ZMM Service Factor Maximum Amps'),
                Forms\Components\TextInput::make('zmm_speed')
                    ->label('ZMM Speed'),
                Forms\Components\TextInput::make('zmm_suction')
                    ->label('ZMM Suction'),
                Forms\Components\TextInput::make('zmm_suctionxdelivery')
                    ->label('ZMM Suction X Delivery'),
                Forms\Components\TextInput::make('zmm_supplysource')
                    ->label('ZMM Supply Source'),
                Forms\Components\TextInput::make('zmm_temperature')
                    ->label('ZMM Temperature'),
                Forms\Components\TextInput::make('zmm_thrustload')
                    ->label('ZMM Thrust Load'),
                Forms\Components\TextInput::make('zmm_volts')
                    ->label('ZMM Volts'),
                Forms\Components\TextInput::make('zmm_wire')
                    ->label('ZMM Wire'),
                Forms\Components\TextInput::make('zmm_package')
                    ->label('ZMM Package'),
                Forms\Components\TextInput::make('zmm_pvarrayrating')
                    ->label('ZMM PV Array Rating'),
                Forms\Components\TextInput::make('zmm_isi')
                    ->label('ZMM ISI'),
                Forms\Components\TextInput::make('zmm_isimotor')
                    ->label('ZMM ISI Motor'),
                Forms\Components\TextInput::make('zmm_isipump')
                    ->label('ZMM ISI Pump'),
                Forms\Components\TextInput::make('zmm_isipumpset')
                    ->label('ZMM ISI Pump Set'),
                Forms\Components\TextInput::make('zmm_pumpset_model')
                    ->label('ZMM Pump Set Model'),
                Forms\Components\TextInput::make('zmm_stages')
                    ->label('ZMM Stages'),
                Forms\Components\TextInput::make('zmm_headrange')
                    ->label('ZMM Head Range'),
                Forms\Components\TextInput::make('zmm_overall_efficiency')
                    ->label('ZMM Overall Efficiency'),
                Forms\Components\TextInput::make('zmm_connection')
                    ->label('ZMM Connection'),
                Forms\Components\TextInput::make('zmm_min_bore_size')
                    ->label('ZMM Min Bore Size'),
                Forms\Components\TextInput::make('zmm_isireference')
                    ->label('ZMM ISI Reference'),
                Forms\Components\TextInput::make('zmm_category')
                    ->label('ZMM Category'),
                Forms\Components\TextInput::make('zmm_submergence')
                    ->label('ZMM Submergence'),
                Forms\Components\TextInput::make('zmm_capacitorstart')
                    ->label('ZMM Capacitor Start'),
                Forms\Components\TextInput::make('zmm_capacitorrun')
                    ->label('ZMM Capacitor Run'),
                Forms\Components\TextInput::make('zmm_inch')
                    ->label('ZMM Inch'),
                Forms\Components\TextInput::make('zmm_motor_type')
                    ->label('ZMM Motor Type'),
                Forms\Components\TextInput::make('zmm_dismantle_direction')
                    ->label('ZMM Dismantle Direction'),
                Forms\Components\TextInput::make('zmm_eff_ovrall')
                    ->label('ZMM Overall Efficiency'),
                Forms\Components\TextInput::make('zmm_bodymoc')
                    ->label('ZMM Body MOC'),
                Forms\Components\TextInput::make('zmm_rotormoc')
                    ->label('ZMM Rotor MOC'),
                Forms\Components\TextInput::make('zmm_dlwl')
                    ->label('ZMM DLWL'),
                Forms\Components\TextInput::make('zmm_inputpower')
                    ->label('ZMM Input Power'),
                Forms\Components\TextInput::make('zmm_imp_od')
                    ->label('ZMM Imp OD'),
                Forms\Components\TextInput::make('zmm_ambtemp')
                    ->label('ZMM Ambient Temperature'),
                Forms\Components\TextInput::make('zmm_de')
                    ->label('ZMM DE'),
                Forms\Components\TextInput::make('zmm_dischargerange')
                    ->label('ZMM Discharge Range'),
                Forms\Components\TextInput::make('zmm_efficiency_class')
                    ->label('ZMM Efficiency Class'),
                Forms\Components\TextInput::make('zmm_framesize')
                    ->label('ZMM Frame Size'),
                Forms\Components\TextInput::make('zmm_impellerdiameter')
                    ->label('ZMM Impeller Diameter'),
                Forms\Components\TextInput::make('zmm_insulationclass')
                    ->label('ZMM Insulation Class'),
                Forms\Components\TextInput::make('zmm_maxflow')
                    ->label('ZMM Max Flow'),
                Forms\Components\TextInput::make('zmm_minhead')
                    ->label('ZMM Min Head'),
                Forms\Components\TextInput::make('zmm_mtrlofconst')
                    ->label('ZMM Motor Load Constant'),
                Forms\Components\TextInput::make('zmm_nde')
                    ->label('ZMM NDE'),
                Forms\Components\TextInput::make('zmm_powerfactor')
                    ->label('ZMM Power Factor'),
                Forms\Components\TextInput::make('zmm_tagno')
                    ->label('ZMM Tag No'),
                Forms\Components\TextInput::make('zmm_year')
                    ->label('ZMM Year'),
                Forms\Components\TextInput::make('zmm_laser_name')
                    ->label('ZMM Laser Name'),
                Forms\Components\TextInput::make('zmm_beenote')
                    ->label('ZMM Bee Note'),
                Forms\Components\TextInput::make('zmm_beenumber')
                    ->label('ZMM Bee Number'),
                Forms\Components\TextInput::make('zmm_beestar')
                    ->label('ZMM Bee Star'),
                Forms\Components\TextInput::make('zmm_logo_ce')
                    ->label('ZMM Logo CE'),
                Forms\Components\TextInput::make('zmm_codeclass')
                    ->label('ZMM Code Class'),
                Forms\Components\TextInput::make('zmm_colour')
                    ->label('ZMM Colour'),
                Forms\Components\TextInput::make('zmm_logo_cp')
                    ->label('ZMM Logo CP'),
                Forms\Components\TextInput::make('zmm_grade')
                    ->label('ZMM Grade'),
                Forms\Components\TextInput::make('zmm_grwt_pset')
                    ->label('ZMM Grwt Pset'),
                Forms\Components\TextInput::make('zmm_grwt_cable')
                    ->label('ZMM Grwt Cable'),
                Forms\Components\TextInput::make('zmm_grwt_motor')
                    ->label('ZMM Grwt Motor'),
                Forms\Components\TextInput::make('zmm_grwt_pf')
                    ->label('ZMM Grwt PF'),
                Forms\Components\TextInput::make('zmm_grwt_pump')
                    ->label('ZMM Grwt Pump'),
                Forms\Components\TextInput::make('zmm_isivalve')
                    ->label('ZMM ISIV Alve'),
                Forms\Components\TextInput::make('zmm_isi_wc')
                    ->label('ZMM ISIV WC'),
                Forms\Components\TextInput::make('zmm_labelperiod')
                    ->label('ZMM Label Period'),
                Forms\Components\TextInput::make('zmm_length')
                    ->label('ZMM Length'),
                Forms\Components\TextInput::make('zmm_license_cml_no')
                    ->label('ZMM License CML No'),
                Forms\Components\TextInput::make('zmm_mfgmonyr')
                    ->label('ZMM Mfg Mon Yr'),
                Forms\Components\TextInput::make('zmm_modelyear')
                    ->label('ZMM Model Year'),
                Forms\Components\TextInput::make('zmm_motoridentification')
                    ->label('ZMM Motor Identification'),
                Forms\Components\TextInput::make('zmm_newt_pset')
                    ->label('ZMM Newt Pset'),
                Forms\Components\TextInput::make('zmm_newt_cable')
                    ->label('ZMM Newt Cable'),
                Forms\Components\TextInput::make('zmm_newt_motor')
                    ->label('ZMM Newt Motor'),
                Forms\Components\TextInput::make('zmm_newt_pf')
                    ->label('ZMM Newt PF'),
                Forms\Components\TextInput::make('zmm_newt_pump')
                    ->label('ZMM Newt Pump'),
                Forms\Components\TextInput::make('zmm_logo_nsf')
                    ->label('ZMM Logo NSF'),
                Forms\Components\TextInput::make('zmm_packtype')
                    ->label('ZMM Pack Type'),
                Forms\Components\TextInput::make('zmm_panel')
                    ->label('ZMM Panel'),
                Forms\Components\TextInput::make('zmm_performance_factor')
                    ->label('ZMM Performance Factor'),
                Forms\Components\TextInput::make('zmm_pumpidentification')
                    ->label('ZMM Pump Identification'),
                Forms\Components\TextInput::make('zmm_psettype')
                    ->label('ZMM Pset Type'),
                Forms\Components\TextInput::make('zmm_size')
                    ->label('ZMM Size'),
                Forms\Components\TextInput::make('zmm_eff_ttl')
                    ->label('ZMM Eff TTL'),
                Forms\Components\TextInput::make('zmm_type')
                    ->label('ZMM Type'),
                Forms\Components\TextInput::make('zmm_usp')
                    ->label('ZMM USP'),
                Forms\Components\TextInput::make('zmm_1')
                    ->label('ZMM 1'),
                Forms\Components\TextInput::make('zmm_2')
                    ->label('ZMM 2'),
                Forms\Components\TextInput::make('zmm_3')
                    ->label('ZMM 3'),
                Forms\Components\TextInput::make('zmm_4')
                    ->label('ZMM 4'),
                Forms\Components\TextInput::make('zmm_5')
                    ->label('ZMM 5'),
                Forms\Components\TextInput::make('zmm_6')
                    ->label('ZMM 6'),
                Forms\Components\TextInput::make('zmm_7')
                    ->label('ZMM 7'),
                Forms\Components\TextInput::make('zmm_8')
                    ->label('ZMM 8'),
                Forms\Components\TextInput::make('zmm_9')
                    ->label('ZMM 9'),
                Forms\Components\TextInput::make('zmm_10')
                    ->label('ZMM 10'),
                Forms\Components\TextInput::make('zmm_11')
                    ->label('ZMM 11'),
                Forms\Components\TextInput::make('zmm_12')
                    ->label('ZMM 12'),
                Forms\Components\TextInput::make('zmm_13')
                    ->label('ZMM 13'),
                Forms\Components\TextInput::make('zmm_14')
                    ->label('ZMM 14'),
                Forms\Components\TextInput::make('zmm_15')
                    ->label('ZMM 15'),
                Forms\Components\Hidden::make('created_by')
                    ->label('Created By')
                    ->default(Filament::auth()->user()?->name),
                Forms\Components\Hidden::make('updated_by')
                    ->label('Updated By')
                    ->default(Filament::auth()->user()?->name),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                // Tables\Columns\TextColumn::make('id')
                //     ->label('ID')
                //     ->numeric()
                //     ->sortable(),
                Tables\Columns\TextColumn::make('No.')
                    ->label('No.')
                    ->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
                        $paginator = $livewire->getTableRecords();
                        $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
                        $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;

                        return ($currentPage - 1) * $perPage + $rowLoop->iteration;
                    }),
                Tables\Columns\TextColumn::make('plant.name')
                    ->label('Plant')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('item.code')
                    ->label('Item Code')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('class')
                    ->label('Class')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zz1_cn_bill_ord')
                    ->label('ZZ1 CN Bill Ord')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_amps')
                    ->label('ZMM Amps')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_brand')
                    ->label('ZMM Brand')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_degreeofprotection')
                    ->label('ZMM Degree of Protection')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_delivery')
                    ->label('ZMM Delivery')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dir_rot')
                    ->label('ZMM Direction Rotation')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge')
                    ->label('ZMM Discharge')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge_max')
                    ->label('ZMM Discharge Max')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_discharge_min')
                    ->label('ZMM Discharge Min')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_duty')
                    ->label('ZMM Duty')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_motor')
                    ->label('ZMM Eff Motor')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_pump')
                    ->label('ZMM Eff Pump')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_frequency')
                    ->label('ZMM Frequency')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head')
                    ->label('ZMM Head')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_heading')
                    ->label('ZMM Heading')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head_max')
                    ->label('ZMM Head Max')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_head_minimum')
                    ->label('ZMM Head Minimum')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_idx_eff_mtr')
                    ->label('ZMM Idx Eff Mtr')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_idx_eff_pump')
                    ->label('ZMM Idx Eff Pump')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_kvacode')
                    ->label('ZMM KVACode')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_maxambtemp')
                    ->label('ZMM Max Amb Temp')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mincoolingflow')
                    ->label('ZMM Min Cooling Flow')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motorseries')
                    ->label('ZMM Motor Series')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motor_model')
                    ->label('ZMM Motor Model')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_outlet')
                    ->label('ZMM Outlet')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_phase')
                    ->label('ZMM Phase')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pressure')
                    ->label('ZMM Pressure')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpflowtype')
                    ->label('ZMM Pump Flow Type')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpseries')
                    ->label('ZMM Pump Series')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pump_model')
                    ->label('ZMM Pump Model')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_ratedpower')
                    ->label('ZMM Rated Power')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_region')
                    ->label('ZMM Region')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_servicefactor')
                    ->label('ZMM Service Factor')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_servicefactormaximumamps')
                    ->label('ZMM Service Factor Maximum Amps')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_speed')
                    ->label('ZMM Speed')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_suction')
                    ->label('ZMM Suction')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_suctionxdelivery')
                    ->label('ZMM Suction X Delivery')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_supplysource')
                    ->label('ZMM Supply Source')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_temperature')
                    ->label('ZMM Temperature')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_thrustload')
                    ->label('ZMM Thrust Load')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_volts')
                    ->label('ZMM Volts')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_wire')
                    ->label('ZMM Wire')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_package')
                    ->label('ZMM Package')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pvarrayrating')
                    ->label('ZMM PV Array Rating')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isi')
                    ->label('ZMM ISI')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isimotor')
                    ->label('ZMM ISI Motor')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isipump')
                    ->label('ZMM ISI Pump')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isipumpset')
                    ->label('ZMM ISI Pump Set')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpset_model')
                    ->label('ZMM Pump Set Model')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_stages')
                    ->label('ZMM Stages')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_headrange')
                    ->label('ZMM Head Range')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_overall_efficiency')
                    ->label('ZMM Overall Efficiency')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_connection')
                    ->label('ZMM Connection')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_min_bore_size')
                    ->label('ZMM Min Bore Size')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isireference')
                    ->label('ZMM ISI Reference')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_category')
                    ->label('ZMM Category')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_submergence')
                    ->label('ZMM Submergence')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_capacitorstart')
                    ->label('ZMM Capacitor Start')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_capacitorrun')
                    ->label('ZMM Capacitor Run')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_inch')
                    ->label('ZMM Inch')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motor_type')
                    ->label('ZMM Motor Type')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dismantle_direction')
                    ->label('ZMM Dismantle Direction')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_ovrall')
                    ->label('ZMM Overall Efficiency')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_bodymoc')
                    ->label('ZMM Body MOC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_rotormoc')
                    ->label('ZMM Rotor MOC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dlwl')
                    ->label('ZMM DLWL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_inputpower')
                    ->label('ZMM Input Power')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_imp_od')
                    ->label('ZMM Imp OD')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_ambtemp')
                    ->label('ZMM Ambient Temperature')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_de')
                    ->label('ZMM DE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_dischargerange')
                    ->label('ZMM Discharge Range')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_efficiency_class')
                    ->label('ZMM Efficiency Class')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_framesize')
                    ->label('ZMM Frame Size')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_impellerdiameter')
                    ->label('ZMM Impeller Diameter')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_insulationclass')
                    ->label('ZMM Insulation Class')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_maxflow')
                    ->label('ZMM Max Flow')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_minhead')
                    ->label('ZMM Min Head')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mtrlofconst')
                    ->label('ZMM Motor Load Constant')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_nde')
                    ->label('ZMM NDE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_powerfactor')
                    ->label('ZMM Power Factor')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_tagno')
                    ->label('ZMM Tag No')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_year')
                    ->label('ZMM Year')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_laser_name')
                    ->label('ZMM Laser Name')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beenote')
                    ->label('ZMM Bee Note')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beenumber')
                    ->label('ZMM Bee Number')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_beestar')
                    ->label('ZMM Bee Star')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_logo_ce')
                    ->label('ZMM Logo CE')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_codeclass')
                    ->label('ZMM Code Class')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_colour')
                    ->label('ZMM Colour')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_logo_cp')
                    ->label('ZMM Logo CP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grade')
                    ->label('ZMM Grade')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_pset')
                    ->label('ZMM Grwt Pset')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_cable')
                    ->label('ZMM Grwt Cable')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_motor')
                    ->label('ZMM Grwt Motor')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_pf')
                    ->label('ZMM Grwt PF')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_grwt_pump')
                    ->label('ZMM Grwt Pump')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isivalve')
                    ->label('ZMM ISIV Alve')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_isi_wc')
                    ->label('ZMM ISIV WC')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_labelperiod')
                    ->label('ZMM Label Period')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_length')
                    ->label('ZMM Length')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_license_cml_no')
                    ->label('ZMM License CML No')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_mfgmonyr')
                    ->label('ZMM Mfg Mon Yr')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_modelyear')
                    ->label('ZMM Model Year')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_motoridentification')
                    ->label('ZMM Motor Identification')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_pset')
                    ->label('ZMM Newt Pset')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_cable')
                    ->label('ZMM Newt Cable')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_motor')
                    ->label('ZMM Newt Motor')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_pf')
                    ->label('ZMM Newt PF')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_newt_pump')
                    ->label('ZMM Newt Pump')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_logo_nsf')
                    ->label('ZMM Logo NSF')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_packtype')
                    ->label('ZMM Pack Type')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_panel')
                    ->label('ZMM Panel')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_performance_factor')
                    ->label('ZMM Performance Factor')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_pumpidentification')
                    ->label('ZMM Pump Identification')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_psettype')
                    ->label('ZMM Pset Type')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_size')
                    ->label('ZMM Size')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_eff_ttl')
                    ->label('ZMM Eff TTL')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_type')
                    ->label('ZMM Type')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_usp')
                    ->label('ZMM USP')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_1')
                    ->label('ZMM 1')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_2')
                    ->label('ZMM 2')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_3')
                    ->label('ZMM 3')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_4')
                    ->label('ZMM 4')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_5')
                    ->label('ZMM 5')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_6')
                    ->label('ZMM 6')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_7')
                    ->label('ZMM 7')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_8')
                    ->label('ZMM 8')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_9')
                    ->label('ZMM 9')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_10')
                    ->label('ZMM 10')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_11')
                    ->label('ZMM 11')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_12')
                    ->label('ZMM 12')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_13')
                    ->label('ZMM 13')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_14')
                    ->label('ZMM 14')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('zmm_15')
                    ->label('ZMM 15')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_by')
                    ->label('Created By')
                    ->alignCenter()
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                Tables\Columns\TextColumn::make('deleted_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                Tables\Filters\TrashedFilter::make(),
            ])
            ->actions([
                Tables\Actions\ViewAction::make(),
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                    Tables\Actions\ForceDeleteBulkAction::make(),
                    Tables\Actions\RestoreBulkAction::make(),
                ]),
            ]);

    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListItemCharacteristics::route('/'),
            'create' => Pages\CreateItemCharacteristic::route('/create'),
            'view' => Pages\ViewItemCharacteristic::route('/{record}'),
            'edit' => Pages\EditItemCharacteristic::route('/{record}/edit'),
        ];
    }

    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);
    }
}
