After Production Quantity and Overall Validation
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Filament\Imports\LineStopImporter;
|
||||
use App\Filament\Resources\LineStopResource\Pages;
|
||||
use App\Filament\Resources\LineStopResource\RelationManagers;
|
||||
use App\Models\LineStop;
|
||||
use Doctrine\DBAL\Exception\InvalidColumnType\ColumnPrecisionRequired;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -14,6 +15,7 @@ use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
|
||||
class LineStopResource extends Resource
|
||||
{
|
||||
@@ -23,16 +25,71 @@ class LineStopResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('code')
|
||||
->required()
|
||||
->autocapitalize(autocapitalize: 'code'),
|
||||
Forms\Components\Textarea::make('reason')
|
||||
->required(),
|
||||
//->columnSpanFull(),
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('code')
|
||||
->required()
|
||||
->alphaNum()
|
||||
->unique(ignoreRecord: true)
|
||||
->minLength(3)
|
||||
->placeholder('Scan the valid code')
|
||||
->autocapitalize(autocapitalize: 'characters')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('code');
|
||||
if (!$code) {
|
||||
$set('lsCodeError', 'Scan the valid code.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($code) < 3) {
|
||||
$set('lsCodeError', 'Code must be at least 3 digits.');
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[a-zA-Z0-9]{3,}$/', $code)) {
|
||||
$set('code',null);
|
||||
$set('lsCodeError', 'Alpha-numeric only allowed.');
|
||||
return;
|
||||
}
|
||||
$set('lsCodeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lsCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lsCodeError') ? $get('lsCodeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('reason')
|
||||
->required()
|
||||
->placeholder('Scan the valid reason')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$reason = $get('reason');
|
||||
if (!$reason) {
|
||||
$set('lsReasonError', 'Scan the valid reason.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('lsReasonError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lsReasonError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lsReasonError') ? $get('lsReasonError') : null)
|
||||
->hintColor('danger')
|
||||
->columnSpan(['default' => 1, 'sm' => 2]),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user