After Production Quantity and Overall Validation
This commit is contained in:
@@ -23,6 +23,8 @@ class PlantResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -32,19 +34,104 @@ class PlantResource extends Resource
|
||||
Forms\Components\TextInput::make('code')
|
||||
->required()
|
||||
->unique(ignoreRecord: true)
|
||||
->numeric()
|
||||
->minValue(1000),
|
||||
->integer()
|
||||
->reactive()
|
||||
->placeholder('Scan the valid code')
|
||||
->minValue(1000)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$codeId = $get('code');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$codeId) {
|
||||
$set('pCodeError', 'Scan the valid code.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($codeId) < 4) {
|
||||
$set('pCodeError', 'Code must be at least 4 digits.');
|
||||
return;
|
||||
}
|
||||
// if (!preg_match('/^[1-9][0-9]{3,}$/', $codeId)) {
|
||||
// $set('code',null);
|
||||
// $set('pCodeError', 'Code should not begin with zero and must contain 4 digit number.');
|
||||
// return;
|
||||
// }
|
||||
$set('pCodeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pCodeError') ? $get('pCodeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('company_id')
|
||||
// ->placeholder('Choose the valid company name')
|
||||
->relationship('company', 'name')
|
||||
->required(),
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$companyId = $get('company_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$companyId) {
|
||||
$set('pCompanyError', 'Please select a company first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('pCompanyError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pCompanyError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pCompanyError') ? $get('pCompanyError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->placeholder('Scan the valid name')
|
||||
->unique(ignoreRecord: true)
|
||||
->columnSpanFull(),
|
||||
->columnSpanFull()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$nameId = $get('name');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$nameId) {
|
||||
$set('pNameError', 'Scan the valid name.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('pNameError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pNameError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pNameError') ? $get('pNameError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Textarea::make('address')
|
||||
->required()
|
||||
->placeholder('Scan the valid address')
|
||||
->unique(ignoreRecord: true)
|
||||
->columnSpanFull(),
|
||||
->columnSpanFull()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$nameId = $get('address');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$nameId) {
|
||||
$set('pAddressError', 'Scan the valid address.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('pAddressError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pAddressError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pAddressError') ? $get('pAddressError') : null)
|
||||
->hintColor('danger'),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user