Updated label and updated_by user name on edit and plant load logic updated on filter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -211,9 +211,9 @@ class MotorTestingMasterImporter extends Importer
|
|||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant')
|
->exampleHeader('Plant Code')
|
||||||
->example(['1000', '1010', '1020'])
|
->example(['1000', '1010', '1020'])
|
||||||
->label('Plant')
|
->label('Plant Code')
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('created_by')
|
ImportColumn::make('created_by')
|
||||||
|
|||||||
@@ -42,9 +42,10 @@ class MotorTestingMasterResource 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')
|
||||||
->required()
|
->required()
|
||||||
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
@@ -64,6 +65,8 @@ class MotorTestingMasterResource extends Resource
|
|||||||
} else {
|
} else {
|
||||||
$set('mTmError', null);
|
$set('mTmError', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('mTmError') ? 'border-red-500' : '',
|
'class' => $get('mTmError') ? 'border-red-500' : '',
|
||||||
@@ -74,6 +77,9 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->label('Routine Test Time')
|
->label('Routine Test Time')
|
||||||
->default('00:40:00')
|
->default('00:40:00')
|
||||||
->required()
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
@@ -84,13 +90,27 @@ class MotorTestingMasterResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $get('id')) {
|
||||||
|
// whereHas
|
||||||
|
return Item::where('plant_id', $plantId)->whereDoesntHave('motorTestingMasters')->pluck('code', 'id');
|
||||||
|
} else {
|
||||||
|
$itemId = MotorTestingMaster::where('id', $get('id'))->first()?->item_id;
|
||||||
|
|
||||||
return Item::where('plant_id', $plantId)
|
return Item::where('plant_id', $plantId)
|
||||||
->pluck('code', 'id')
|
->where(function ($query) use ($itemId) {
|
||||||
->toArray();
|
$query->whereDoesntHave('motorTestingMasters')
|
||||||
|
->orWhere('id', $itemId);
|
||||||
|
})
|
||||||
|
->pluck('code', 'id');
|
||||||
|
}
|
||||||
|
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->rule(function (callable $get) {
|
->rule(function (callable $get) {
|
||||||
return Rule::unique('motor_testing_masters', 'item_id')
|
return Rule::unique('motor_testing_masters', 'item_id')
|
||||||
->where('plant_id', $get('plant_id'))
|
->where('plant_id', $get('plant_id'))
|
||||||
@@ -122,6 +142,8 @@ class MotorTestingMasterResource extends Resource
|
|||||||
}
|
}
|
||||||
$set('iCodeError', null);
|
$set('iCodeError', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||||
@@ -138,6 +160,9 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->default(1)
|
->default(1)
|
||||||
->required()
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\Select::make('phase')
|
Forms\Components\Select::make('phase')
|
||||||
->label('Phase')
|
->label('Phase')
|
||||||
@@ -159,35 +184,57 @@ class MotorTestingMasterResource extends Resource
|
|||||||
})
|
})
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|
||||||
if ($state == 'Single' && $get('connection') == 'Star-Delta') {
|
if ($state == 'Single' && $get('connection') == 'Star-Delta') {
|
||||||
$set('phase', 'Three');
|
$set('phase', 'Three');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->default('Single')
|
->default('Single')
|
||||||
->required()
|
->required()
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\TextInput::make('hp')
|
Forms\Components\TextInput::make('hp')
|
||||||
->label('HP')
|
->label('HP')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('kw')
|
Forms\Components\TextInput::make('kw')
|
||||||
->label('KW')
|
->label('KW')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('volt')
|
Forms\Components\TextInput::make('volt')
|
||||||
->label('Volt')
|
->label('Volt')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('current')
|
Forms\Components\TextInput::make('current')
|
||||||
->label('Current')
|
->label('Current')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('rpm')
|
Forms\Components\TextInput::make('rpm')
|
||||||
->label('RPM')
|
->label('RPM')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('torque')
|
Forms\Components\TextInput::make('torque')
|
||||||
->label('Torque')
|
->label('Torque')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('frequency')
|
Forms\Components\TextInput::make('frequency')
|
||||||
->label('Frequency')
|
->label('Frequency')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Select::make('connection')
|
Forms\Components\Select::make('connection')
|
||||||
->label('Connection')
|
->label('Connection')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
@@ -210,12 +257,17 @@ class MotorTestingMasterResource extends Resource
|
|||||||
if ($state == 'Star-Delta') {
|
if ($state == 'Star-Delta') {
|
||||||
$set('phase', 'Three');
|
$set('phase', 'Three');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->default('Star')
|
->default('Star')
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\TextInput::make('ins_res_limit')
|
Forms\Components\TextInput::make('ins_res_limit')
|
||||||
->label('Insulation Resistance Limit')
|
->label('Insulation Resistance Limit')
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('ins_res_type')
|
Forms\Components\Select::make('ins_res_type')
|
||||||
->label('Insulation Resistance Type')
|
->label('Insulation Resistance Type')
|
||||||
@@ -236,55 +288,106 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_ry_ll')
|
Forms\Components\TextInput::make('res_ry_ll')
|
||||||
->label('Resistance RY LL')
|
->label('Resistance RY LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_ry_ul')
|
Forms\Components\TextInput::make('res_ry_ul')
|
||||||
->label('Resistance RY UL')
|
->label('Resistance RY UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_yb_ll')
|
Forms\Components\TextInput::make('res_yb_ll')
|
||||||
->label('Resistance YB LL')
|
->label('Resistance YB LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_yb_ul')
|
Forms\Components\TextInput::make('res_yb_ul')
|
||||||
->label('Resistance YB UL')
|
->label('Resistance YB UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_br_ll')
|
Forms\Components\TextInput::make('res_br_ll')
|
||||||
->label('Resistance BR LL')
|
->label('Resistance BR LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('res_br_ul')
|
Forms\Components\TextInput::make('res_br_ul')
|
||||||
->label('Resistance BR UL')
|
->label('Resistance BR UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('lock_volt_limit')
|
Forms\Components\TextInput::make('lock_volt_limit')
|
||||||
->label('Lock Volt Limit')
|
->label('Lock Volt Limit')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('leak_cur_limit')
|
Forms\Components\TextInput::make('leak_cur_limit')
|
||||||
->label('Leakage Current Limit')
|
->label('Leakage Current Limit')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('lock_cur_ll')
|
Forms\Components\TextInput::make('lock_cur_ll')
|
||||||
->label('Lock Current LL')
|
->label('Lock Current LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('lock_cur_ul')
|
Forms\Components\TextInput::make('lock_cur_ul')
|
||||||
->label('Lock Current UL')
|
->label('Lock Current UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_cur_ll')
|
Forms\Components\TextInput::make('noload_cur_ll')
|
||||||
->label('No Load Current LL')
|
->label('No Load Current LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_cur_ul')
|
Forms\Components\TextInput::make('noload_cur_ul')
|
||||||
->label('No Load Current UL')
|
->label('No Load Current UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_pow_ll')
|
Forms\Components\TextInput::make('noload_pow_ll')
|
||||||
->label('No Load Power LL')
|
->label('No Load Power LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_pow_ul')
|
Forms\Components\TextInput::make('noload_pow_ul')
|
||||||
->label('No Load Power UL')
|
->label('No Load Power UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_spd_ll')
|
Forms\Components\TextInput::make('noload_spd_ll')
|
||||||
->label('No Load Speed LL')
|
->label('No Load Speed LL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('noload_spd_ul')
|
Forms\Components\TextInput::make('noload_spd_ul')
|
||||||
->label('No Load Speed UL')
|
->label('No Load Speed UL')
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->default(fn () => Filament::auth()->user()?->name)
|
->default(fn () => Filament::auth()->user()?->name)
|
||||||
->required(),
|
->required(),
|
||||||
@@ -311,7 +414,7 @@ class MotorTestingMasterResource 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')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -458,17 +561,26 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->label('Advanced Filters')
|
->label('Advanced Filters')
|
||||||
->form([
|
->form([
|
||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
->label('Select Plant')
|
->label('Search by Plant Name')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
// ->options(function () {
|
// ->options(function () {
|
||||||
// return Plant::pluck('name', 'id');
|
// return Plant::pluck('name', 'id');
|
||||||
// })
|
// })
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('motorTestingMasters', 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();
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
$set('Item', null);
|
||||||
$set('isi_type', null);
|
$set('isi_type', null);
|
||||||
@@ -681,7 +793,7 @@ class MotorTestingMasterResource 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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user