Added validation for process order with item code
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / review (pull_request) Failing after 23s
Laravel Pint / pint (pull_request) Successful in 2m34s
Laravel Larastan / larastan (pull_request) Failing after 3m9s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / review (pull_request) Failing after 23s
Laravel Pint / pint (pull_request) Successful in 2m34s
Laravel Larastan / larastan (pull_request) Failing after 3m9s
This commit is contained in:
@@ -144,6 +144,34 @@ class ProcessOrderResource extends Resource
|
||||
$set('sfgNumberError', null);
|
||||
}
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return function (string $attribute, $value, \Closure $fail) use ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
$processOrder = $value;
|
||||
//$currentId = $get('id'); // current editing record id
|
||||
|
||||
if (! $plantId || ! $processOrder) {
|
||||
return;
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', '!=', $itemId)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate Process Order!')
|
||||
->body("Process Order '{$value}' is already exist with item code '{$existing->item->code}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$fail("process order already exists for this plant and item code '{$existing->item->code}'.");
|
||||
}
|
||||
};
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('coil_number')
|
||||
->label('Coil Number')
|
||||
|
||||
Reference in New Issue
Block a user