Added inter unit staff logic in visitor entry page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 2m4s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 1m3s
Laravel Pint / pint (pull_request) Successful in 3m0s
Laravel Larastan / larastan (pull_request) Failing after 4m25s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 2m4s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 1m3s
Laravel Pint / pint (pull_request) Successful in 3m0s
Laravel Larastan / larastan (pull_request) Failing after 4m25s
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Filament\Resources\VisitorEntryResource\Pages;
|
|||||||
use App\Filament\Resources\VisitorEntryResource\RelationManagers;
|
use App\Filament\Resources\VisitorEntryResource\RelationManagers;
|
||||||
use App\Models\VisitorEntry;
|
use App\Models\VisitorEntry;
|
||||||
use App\Models\EmployeeMaster;
|
use App\Models\EmployeeMaster;
|
||||||
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -63,6 +64,47 @@ class VisitorEntryResource extends Resource
|
|||||||
return $prefix . $nextNumber;
|
return $prefix . $nextNumber;
|
||||||
})
|
})
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
|
Forms\Components\Select::make('inter_unit')
|
||||||
|
->label('Inter Unit Staff Code')
|
||||||
|
->options(
|
||||||
|
EmployeeMaster::distinct()
|
||||||
|
->orderBy('code')
|
||||||
|
->pluck('code', 'code')
|
||||||
|
)
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
||||||
|
|
||||||
|
$code = $get('inter_unit');
|
||||||
|
|
||||||
|
if($code){
|
||||||
|
$employeeExist = EmployeeMaster::where('code', $code)->first();
|
||||||
|
|
||||||
|
$plantId = $employeeExist->plant_id;
|
||||||
|
|
||||||
|
$plant = Plant::find($plantId);
|
||||||
|
|
||||||
|
if ($employeeExist) {
|
||||||
|
$set('name', $employeeExist->name);
|
||||||
|
$set('mobile_number', $employeeExist->mobile_number);
|
||||||
|
$set('company', $plant->name);
|
||||||
|
$set('type', 'InterUnitStaff');
|
||||||
|
} else {
|
||||||
|
$set('name', null);
|
||||||
|
$set('mobile_number', null);
|
||||||
|
$set('company', null);
|
||||||
|
$set('type', null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$set('name', null);
|
||||||
|
$set('mobile_number', null);
|
||||||
|
$set('company', null);
|
||||||
|
$set('type', null);
|
||||||
|
|
||||||
|
}
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('mobile_number')
|
Forms\Components\TextInput::make('mobile_number')
|
||||||
->label('Mobile Number')
|
->label('Mobile Number')
|
||||||
->length(10)
|
->length(10)
|
||||||
@@ -72,6 +114,7 @@ class VisitorEntryResource extends Resource
|
|||||||
'maxlength' => 10,
|
'maxlength' => 10,
|
||||||
])
|
])
|
||||||
->required()
|
->required()
|
||||||
|
->readOnly(fn (callable $get) => filled($get('inter_unit')))
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'id' => 'mobile_number_input',
|
'id' => 'mobile_number_input',
|
||||||
'x-data' => '{ value: "" }',
|
'x-data' => '{ value: "" }',
|
||||||
@@ -82,9 +125,14 @@ class VisitorEntryResource extends Resource
|
|||||||
->label('Name')
|
->label('Name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->readOnly(fn (callable $get) => filled($get('inter_unit')))
|
||||||
->extraInputAttributes([
|
->extraInputAttributes([
|
||||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',
|
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',
|
||||||
]),
|
]),
|
||||||
|
Forms\Components\TextInput::make('company')
|
||||||
|
->label('Company')
|
||||||
|
->readOnly(fn (callable $get) => filled($get('inter_unit')))
|
||||||
|
->required(),
|
||||||
Forms\Components\Select::make('type')
|
Forms\Components\Select::make('type')
|
||||||
->label('Type')
|
->label('Type')
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -92,6 +140,7 @@ class VisitorEntryResource extends Resource
|
|||||||
'Student' => 'Student',
|
'Student' => 'Student',
|
||||||
'Consultant' => 'Consultant',
|
'Consultant' => 'Consultant',
|
||||||
'Supplier' => 'Supplier',
|
'Supplier' => 'Supplier',
|
||||||
|
'InterUnitStaff' => 'Inter Unit Staff',
|
||||||
'InterviewCandidates' => 'Interview Candidates',
|
'InterviewCandidates' => 'Interview Candidates',
|
||||||
'Customers/Dealers' => 'Customers/Dealers',
|
'Customers/Dealers' => 'Customers/Dealers',
|
||||||
'Bankers' => 'Bankers',
|
'Bankers' => 'Bankers',
|
||||||
@@ -104,6 +153,24 @@ class VisitorEntryResource extends Resource
|
|||||||
return $state == 'Other'
|
return $state == 'Other'
|
||||||
? $get('other_type')
|
? $get('other_type')
|
||||||
: $state;
|
: $state;
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
||||||
|
|
||||||
|
$code = $get('inter_unit');
|
||||||
|
|
||||||
|
if($code){
|
||||||
|
$set('inter_unit', null);
|
||||||
|
$set('name', null);
|
||||||
|
$set('mobile_number', null);
|
||||||
|
$set('company', null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$set('inter_unit', null);
|
||||||
|
$set('name', null);
|
||||||
|
$set('mobile_number', null);
|
||||||
|
$set('company', null);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('other_type')
|
Forms\Components\TextInput::make('other_type')
|
||||||
->label('Specify Type')
|
->label('Specify Type')
|
||||||
@@ -111,9 +178,6 @@ class VisitorEntryResource extends Resource
|
|||||||
->visible(fn (callable $get) => $get('type') == 'Other')
|
->visible(fn (callable $get) => $get('type') == 'Other')
|
||||||
->required(fn (callable $get) => $get('type') == 'Other')
|
->required(fn (callable $get) => $get('type') == 'Other')
|
||||||
->dehydrated(false),
|
->dehydrated(false),
|
||||||
Forms\Components\TextInput::make('company')
|
|
||||||
->label('Company')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('department')
|
Forms\Components\Select::make('department')
|
||||||
->label('Employee Department')
|
->label('Employee Department')
|
||||||
->options(
|
->options(
|
||||||
|
|||||||
Reference in New Issue
Block a user