Added unique rule for item_id column
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s

This commit is contained in:
dhanabalan
2026-02-26 12:16:50 +05:30
parent f4b7ce19c0
commit 6cbcb2662a

View File

@@ -27,6 +27,8 @@ use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
use Str;
class ProductCharacteristicsMasterResource extends Resource
{
@@ -71,12 +73,31 @@ class ProductCharacteristicsMasterResource extends Resource
return [];
}
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
return Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->rules([
function (callable $get) {
return Rule::unique('product_characteristics_masters', 'item_id')
->where('plant_id', $get('plant_id'))
->where('line_id', $get('line_id'))
->where('work_group_master_id', $get('work_group_master_id'))
->where('machine_id', $get('machine_id'))
// ->where('characteristics_type', $get('characteristics_type'))
->ignore($get('id'));
},
// function (callable $get): Closure {
// return function (string $attribute, $value, Closure $fail) use ($get) {
// $rework = $get('rework_status');
// if ($value && Str::contains($value, '.') && $rework == 0) {
// $fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
// }
// };
// },
])
->required(),
Forms\Components\Select::make('line_id')
->label('Line')