Updated validation logic in resource file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-04-02 17:51:24 +05:30
parent e90973ea23
commit 9512ff4036

View File

@@ -56,8 +56,9 @@ class TestingPanelReadingResource extends Resource
return $form return $form
->schema([ ->schema([
Forms\Components\Select::make('plant_id') Forms\Components\Select::make('plant_id')
->label('Plant') ->label('Plant Name')
->relationship('plant', 'name') ->relationship('plant', 'name')
->searchable()
->required() ->required()
->reactive() ->reactive()
->options(function (callable $get) { ->options(function (callable $get) {
@@ -73,17 +74,19 @@ class TestingPanelReadingResource extends Resource
$plantId = $get('plant_id'); $plantId = $get('plant_id');
if (! $plantId) { if (! $plantId) {
$set('line_id', null); $set('line_id', null);
$set('item_id', null); $set('motor_testing_master_id', null);
$set('machine_id', null); $set('machine_id', null);
$set('tPrError', 'Please select a plant first.'); $set('tPrError', 'Please select a plant first.');
return; return;
} else { } else {
$set('line_id', null); $set('line_id', null);
$set('item_id', null); $set('motor_testing_master_id', null);
$set('machine_id', null); $set('machine_id', null);
$set('tPrError', null); $set('tPrError', null);
} }
$set('updated_by', Filament::auth()->user()?->name);
}) })
->extraAttributes(fn ($get) => [ ->extraAttributes(fn ($get) => [
'class' => $get('tPrError') ? 'border-red-500' : '', 'class' => $get('tPrError') ? 'border-red-500' : '',
@@ -91,8 +94,9 @@ class TestingPanelReadingResource extends Resource
->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null) ->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null)
->hintColor('danger'), ->hintColor('danger'),
Forms\Components\Select::make('line_id') Forms\Components\Select::make('line_id')
->label('Line') ->label('Line Name')
->relationship('line', 'name') ->relationship('line', 'name')
->searchable()
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('plant_id'); $plantId = $get('plant_id');
if (! $plantId) { if (! $plantId) {
@@ -109,10 +113,14 @@ class TestingPanelReadingResource extends Resource
->disabled(fn (Get $get) => ! empty($get('id'))) ->disabled(fn (Get $get) => ! empty($get('id')))
->required() ->required()
->reactive() ->reactive()
->afterStateUpdated(fn (callable $set) => $set('item_id', null)), ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('motor_testing_master_id', null);
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\Select::make('machine_id') Forms\Components\Select::make('machine_id')
->label('Machine') ->label('Work Center')
->relationship('machine', 'name') ->relationship('machine', 'work_center')
->searchable()
->options(function (callable $get) { ->options(function (callable $get) {
$lineId = $get('line_id'); $lineId = $get('line_id');
if (! $lineId) { if (! $lineId) {
@@ -121,7 +129,7 @@ class TestingPanelReadingResource extends Resource
// Only show machines for the selected line // Only show machines for the selected line
return Machine::where('line_id', $lineId) return Machine::where('line_id', $lineId)
->pluck('name', 'id') ->pluck('work_center', 'id')
->toArray(); ->toArray();
}) })
->default(function () { ->default(function () {
@@ -129,7 +137,10 @@ class TestingPanelReadingResource extends Resource
}) })
->disabled(fn (Get $get) => ! empty($get('id'))) ->disabled(fn (Get $get) => ! empty($get('id')))
->required() ->required()
->reactive(), ->reactive()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\Select::make('motor_testing_master_id') Forms\Components\Select::make('motor_testing_master_id')
->label('Item Code') ->label('Item Code')
// ->relationship('motorTestingMaster', 'item.code') // ->relationship('motorTestingMaster', 'item.code')
@@ -163,101 +174,234 @@ class TestingPanelReadingResource extends Resource
// ) // )
->required() ->required()
->searchable() ->searchable()
->reactive(), ->reactive()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('output') Forms\Components\TextInput::make('output')
->label('Output') ->label('Output')
->required(), ->required()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('serial_number') Forms\Components\TextInput::make('serial_number')
->label('Serial Number') ->label('Serial Number')
->required(), ->required()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('winded_serial_number') Forms\Components\TextInput::make('winded_serial_number')
->label('Winded Serial Number'), ->label('Winded Serial Number')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_volt') Forms\Components\TextInput::make('before_fr_volt')
->label('Before FR Volt'), ->label('Before FR Volt')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_cur') Forms\Components\TextInput::make('before_fr_cur')
->label('Before FR Current'), ->label('Before FR Current')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_pow') Forms\Components\TextInput::make('before_fr_pow')
->label('Before FR Power'), ->label('Before FR Power')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_res_ry') Forms\Components\TextInput::make('before_fr_res_ry')
->label('Before FR Resistance RY'), ->label('Before FR Resistance RY')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_res_yb') Forms\Components\TextInput::make('before_fr_res_yb')
->label('Before FR Resistance YB'), ->label('Before FR Resistance YB')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_res_br') Forms\Components\TextInput::make('before_fr_res_br')
->label('Before FR Resistance BR'), ->label('Before FR Resistance BR')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_ir') Forms\Components\TextInput::make('before_fr_ir')
->label('Before FR IR'), ->label('Before FR IR')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_ir_r') Forms\Components\TextInput::make('before_fr_ir_r')
->label('Before FR IR R'), ->label('Before FR IR R')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_ir_y') Forms\Components\TextInput::make('before_fr_ir_y')
->label('Before FR IR Y'), ->label('Before FR IR Y')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_ir_b') Forms\Components\TextInput::make('before_fr_ir_b')
->label('Before FR IR B'), ->label('Before FR IR B')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_freq') Forms\Components\TextInput::make('before_fr_freq')
->label('Before FR Frequency'), ->label('Before FR Frequency')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('before_fr_speed') Forms\Components\TextInput::make('before_fr_speed')
->label('Before FR Speed'), ->label('Before FR Speed')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_vol') Forms\Components\TextInput::make('after_fr_vol')
->label('After FR Volt'), ->label('After FR Volt')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_cur') Forms\Components\TextInput::make('after_fr_cur')
->label('After FR Current'), ->label('After FR Current')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_pow') Forms\Components\TextInput::make('after_fr_pow')
->label('After FR Power'), ->label('After FR Power')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_hot') Forms\Components\TextInput::make('after_fr_ir_hot')
->label('After FR IR Hot'), ->label('After FR IR Hot')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_hot_r') Forms\Components\TextInput::make('after_fr_ir_hot_r')
->label('After FR IR Hot R'), ->label('After FR IR Hot R')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_hot_y') Forms\Components\TextInput::make('after_fr_ir_hot_y')
->label('After FR IR Hot Y'), ->label('After FR IR Hot Y')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_hot_b') Forms\Components\TextInput::make('after_fr_ir_hot_b')
->label('After FR IR Hot B'), ->label('After FR IR Hot B')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_cool') Forms\Components\TextInput::make('after_fr_ir_cool')
->label('After FR IR Cool'), ->label('After FR IR Cool')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_cool_r') Forms\Components\TextInput::make('after_fr_ir_cool_r')
->label('After FR IR Cool R'), ->label('After FR IR Cool R')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_cool_y') Forms\Components\TextInput::make('after_fr_ir_cool_y')
->label('After FR IR Cool Y'), ->label('After FR IR Cool Y')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_ir_cool_b') Forms\Components\TextInput::make('after_fr_ir_cool_b')
->label('After FR IR Cool B'), ->label('After FR IR Cool B')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_freq') Forms\Components\TextInput::make('after_fr_freq')
->label('After FR Frequency'), ->label('After FR Frequency')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_speed') Forms\Components\TextInput::make('after_fr_speed')
->label('After FR Speed'), ->label('After FR Speed')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('after_fr_leak_cur') Forms\Components\TextInput::make('after_fr_leak_cur')
->label('After FR Leak Current'), ->label('After FR Leak Current')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('locked_rt_volt') Forms\Components\TextInput::make('locked_rt_volt')
->label('Locked RT Volt'), ->label('Locked RT Volt')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('locked_rt_cur') Forms\Components\TextInput::make('locked_rt_cur')
->label('Locked RT Current'), ->label('Locked RT Current')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('locked_rt_pow') Forms\Components\TextInput::make('locked_rt_pow')
->label('Locked RT Power'), ->label('Locked RT Power')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('no_load_pickup_volt') Forms\Components\TextInput::make('no_load_pickup_volt')
->label('No Load Pickup Volt'), ->label('No Load Pickup Volt')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('room_temperature') Forms\Components\TextInput::make('room_temperature')
->label('Room Temperature'), ->label('Room Temperature')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('hv_test') Forms\Components\TextInput::make('hv_test')
->label('High Voltage Test'), ->label('High Voltage Test')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('batch_number') Forms\Components\TextInput::make('batch_number')
->label('Batch Number'), ->label('Batch Number')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('batch_count') Forms\Components\TextInput::make('batch_count')
->label('Batch Count') ->label('Batch Count')
->default('0'), ->default('0')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('result') Forms\Components\TextInput::make('result')
->label('Result'), ->label('Result')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('remark') Forms\Components\TextInput::make('remark')
->label('Remark'), ->label('Remark')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('rework_count') Forms\Components\TextInput::make('rework_count')
->label('Rework Count') ->label('Rework Count')
->default('0'), ->default('0')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('update_count') Forms\Components\TextInput::make('update_count')
->label('Update Count') ->label('Update Count')
->default('0'), ->default('0')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('output_flag') Forms\Components\TextInput::make('output_flag')
->label('Output Flag') ->label('Output Flag')
->default('0'), ->default('0')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('tested_by') Forms\Components\TextInput::make('tested_by')
->label('Tested By'), ->label('Tested By')
->default(fn () => Filament::auth()->user()?->name)
->required(),
Forms\Components\TextInput::make('updated_by') Forms\Components\TextInput::make('updated_by')
->label('Updated By'), ->label('Updated By')
->default(fn () => Filament::auth()->user()?->name)
->required(),
Forms\Components\TextInput::make('id') Forms\Components\TextInput::make('id')
->hidden() ->hidden()
->readOnly(), ->readOnly(),
@@ -283,17 +427,20 @@ class TestingPanelReadingResource extends Resource
return ($currentPage - 1) * $perPage + $rowLoop->iteration; return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}), }),
Tables\Columns\TextColumn::make('plant.name') Tables\Columns\TextColumn::make('plant.name')
->label('Plant') ->label('Plant Name')
->alignCenter(), ->alignCenter(),
Tables\Columns\TextColumn::make('line.name') Tables\Columns\TextColumn::make('line.name')
->label('Line') ->label('Line Name')
->alignCenter(), ->alignCenter(),
Tables\Columns\TextColumn::make('machine.name') Tables\Columns\TextColumn::make('machine.work_center')
->label('Machine') ->label('Work Center')
->alignCenter(), ->alignCenter(),
Tables\Columns\TextColumn::make('motorTestingMaster.item.code') Tables\Columns\TextColumn::make('motorTestingMaster.item.code')
->label('Item Code') ->label('Item Code')
->alignCenter(), ->alignCenter(),
Tables\Columns\TextColumn::make('motorTestingMaster.subassembly_code')
->label('Subassembly Code')
->alignCenter(),
Tables\Columns\TextColumn::make('motorTestingMaster.item.description') Tables\Columns\TextColumn::make('motorTestingMaster.item.description')
->label('Model') ->label('Model')
->alignCenter(), ->alignCenter(),
@@ -477,13 +624,22 @@ class TestingPanelReadingResource extends Resource
->label('Advanced Filters') ->label('Advanced Filters')
->form([ ->form([
Select::make('Plant') Select::make('Plant')
->label('Select Plant') ->label('Search by Plant Name')
->searchable()
->nullable() ->nullable()
->options(function () { ->options(function () {
// return Plant::pluck('name', 'id'); // return Plant::pluck('name', 'id');
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
} else {
return Plant::whereHas('testingPanelReadings', function ($query) {
$query->whereNotNull('id');
})->orderBy('code')->pluck('name', 'id');
}
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); //return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
}) })
->reactive() ->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -492,7 +648,8 @@ class TestingPanelReadingResource extends Resource
}), }),
Select::make('Line') Select::make('Line')
->label('Select Line') ->label('Search by Line Name')
->searchable()
->nullable() ->nullable()
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
@@ -507,11 +664,11 @@ class TestingPanelReadingResource extends Resource
->reactive() ->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('item_code', null); $set('item_code', null);
}), }),
Select::make('item_code') Select::make('item_code')
->label('Item Code') ->label('Search by Item Code')
->searchable() ->searchable()
->nullable()
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
if ($plantId) { if ($plantId) {
@@ -520,15 +677,20 @@ class TestingPanelReadingResource extends Resource
->pluck('code', 'id') ->pluck('code', 'id')
->toArray(); ->toArray();
} else { } else {
return Item::whereHas('motorTestingMasters') return [];
->pluck('code', 'id') // return Item::whereHas('motorTestingMasters')
->toArray(); // ->pluck('code', 'id')
// ->toArray();
} }
// return [];
}) })
->reactive(), ->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('item_description', null);
}),
Select::make('machine_name') Select::make('machine_name')
->label('Machine Name') ->label('Search by Work Center')
->searchable()
->nullable()
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
$lineId = $get('Line'); $lineId = $get('Line');
@@ -539,30 +701,43 @@ class TestingPanelReadingResource extends Resource
return Machine::where('plant_id', $plantId) return Machine::where('plant_id', $plantId)
->where('line_id', $lineId) ->where('line_id', $lineId)
->pluck('name', 'id') ->pluck('work_center', 'id')
->toArray(); ->toArray();
}) })
->reactive(), ->reactive(),
TextInput::make('serial_number') TextInput::make('serial_number')
->label('Serial Number') ->label('Serial Number')
->reactive() ->reactive()
->placeholder(placeholder: 'Enter Serial Number'), ->placeholder('Enter Serial Number'),
Select::make('item_description') Select::make('item_description')
->label('Model') ->label('Model')
->searchable() ->searchable()
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
$query = Item::query(); // $query = Item::query();
// if ($plantId) {
// $query->where('plant_id', $plantId);
// }
$plantId = $get('Plant');
if ($plantId) { if ($plantId) {
$query->where('plant_id', $plantId); return Item::where('plant_id', $plantId)
->whereHas('motorTestingMasters')
->pluck('description', 'id')
->toArray();
} else {
return [];
// return Item::whereHas('motorTestingMasters')
// ->pluck('description', 'id')
// ->toArray();
} }
//return $query->pluck('description', 'description')->toArray();
return $query->pluck('description', 'description')->toArray();
}) })
->reactive(), ->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('item_code', null);
}),
Select::make('output') Select::make('output')
->label('Output') ->label('Output')
->searchable() ->searchable()
@@ -702,12 +877,23 @@ class TestingPanelReadingResource extends Resource
} }
if (! empty($data['item_description'])) { if (! empty($data['item_description'])) {
$item = Item::where('description', $data['item_description'])->first(); $itemId = $data['item_description']; // Item::where('description', $data['item_description'])->first()?->id ?? null;
if ($item) { if ($itemId) { // $item
$query->whereHas('motorTestingMaster', function ($subQuery) use ($item) { $mastId = MotorTestingMaster::where('item_id', $itemId)->first()?->id ?? null;
$subQuery->where('item_id', $item->id); if ($mastId) { // $item
}); $motId = TestingPanelReading::where('motor_testing_master_id', $mastId)->first()?->id ?? null;
if ($motId) { // $item
$query->where('motor_testing_master_id', $mastId);
// $query->whereHas('motorTestingMaster', function ($subQuery) use ($itemId) {
// $subQuery->where('item_id', $itemId); //$item->id
// });
} else {
$query->whereRaw('1 = 0');
}
} else {
$query->whereRaw('1 = 0');
}
} else { } else {
$query->whereRaw('1 = 0'); $query->whereRaw('1 = 0');
} }
@@ -756,7 +942,7 @@ class TestingPanelReadingResource extends Resource
$indicators = []; $indicators = [];
if (! empty($data['Plant'])) { if (! empty($data['Plant'])) {
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name'); $indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
} else { } else {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
@@ -765,26 +951,27 @@ class TestingPanelReadingResource extends Resource
} }
} }
if (! empty($data['Line'])) { if (! empty($data['Line'])) {
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name'); $indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
} }
if (! empty($data['item_code'])) { if (! empty($data['item_code'])) {
$indicators[] = 'Item Code: '.Item::where('id', $data['item_code'])->value('code'); $indicators[] = 'Item Code: '.Item::where('id', $data['item_code'])->value('code');
} }
if (! empty($data['machine_name'])) { if (! empty($data['machine_name'])) {
$indicators[] = 'Machine: '.Machine::where('id', $data['machine_name'])->value('name'); $indicators[] = 'Work Center: '.Machine::where('id', $data['machine_name'])->value('work_center');
} }
if (! empty($data['output'])) { if (! empty($data['output'])) {
$indicators[] = 'Output: '.$data['output']; $indicators[] = 'Output: '.$data['output'];
} }
if (! empty($data['item_description'])) { if (! empty($data['item_description'])) {
$indicators[] = 'Model: '.$data['item_description']; $item = Item::where('id', $data['item_description'])->first()?->description ?? null;
$indicators[] = 'Model: '.$item;
} }
// if (!empty($data['phase'])) { // if (!empty($data['phase'])) {
// $indicators[] = 'Phase: ' . $data['phase']; // $indicators[] = 'Phase: ' . $data['phase'];
// } // }
// if (!empty($data['connection'])) { if (!empty($data['connection'])) {
// $indicators[] = 'Connection: ' . $data['connection']; $indicators[] = 'Connection: ' . $data['connection'];
// } }
if (! empty($data['remark'])) { if (! empty($data['remark'])) {
$indicators[] = 'Remark: '.$data['remark']; $indicators[] = 'Remark: '.$data['remark'];
} }