Added unique rule for item_id column
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
This commit is contained in:
@@ -27,6 +27,8 @@ use Filament\Tables\Filters\Filter;
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Str;
|
||||||
|
|
||||||
class ProductCharacteristicsMasterResource extends Resource
|
class ProductCharacteristicsMasterResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -71,12 +73,31 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
return [];
|
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')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$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(),
|
->required(),
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->label('Line')
|
->label('Line')
|
||||||
|
|||||||
Reference in New Issue
Block a user