add user profile data to loan orders
This commit is contained in:
@@ -22,6 +22,7 @@ use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Wizard;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -84,7 +85,7 @@ class LoanOrderForm
|
||||
->schema([
|
||||
Select::make('loan_type')
|
||||
->label(__('Loan type'))
|
||||
->relationship('loanType', 'name')
|
||||
->relationship('loanType', 'name', fn (Builder $query) => $query->orderByTranslation('name'))
|
||||
->required(),
|
||||
|
||||
TextInput::make('loan_amount')
|
||||
@@ -109,6 +110,8 @@ class LoanOrderForm
|
||||
Select::make('branch_id')
|
||||
->label(__('Branch'))
|
||||
->relationship('branch', 'name', function ($query, callable $get) {
|
||||
$query->orderByTranslation('name');
|
||||
|
||||
$region = $get('region');
|
||||
if ($region) {
|
||||
$query->where('region', $region);
|
||||
@@ -125,18 +128,21 @@ class LoanOrderForm
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autocomplete(Str::random(10)),
|
||||
->autocomplete(Str::random(10))
|
||||
->default(user()->first_name),
|
||||
|
||||
TextInput::make('customer_surname')
|
||||
->label(__('Surname'))
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->maxLength(255),
|
||||
->maxLength(255)
|
||||
->default(user()->last_name),
|
||||
|
||||
TextInput::make('customer_patronic_name')
|
||||
->label(__('Patronic name'))
|
||||
->columnSpan(2)
|
||||
->maxLength(255),
|
||||
->maxLength(255)
|
||||
->default(user()->getOption('patronic_name')),
|
||||
|
||||
DatePicker::make('born_at')
|
||||
->displayFormat('d.m.Y')
|
||||
@@ -144,7 +150,8 @@ class LoanOrderForm
|
||||
->native(false)
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
->beforeOrEqual('today')
|
||||
->default(user()->getOption('born_at')),
|
||||
|
||||
FusedGroup::make([
|
||||
Select::make('passport_serie')
|
||||
@@ -152,13 +159,15 @@ class LoanOrderForm
|
||||
->options(TurkmenPassportRepository::values())
|
||||
->native(false)
|
||||
->required()
|
||||
->columnSpan(1),
|
||||
->columnSpan(1)
|
||||
->default(user()->getOption('passport_serie')),
|
||||
|
||||
TextInput::make('passport_id')
|
||||
->label(__('Passport number'))
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->mask('999999'),
|
||||
->mask('999999')
|
||||
->default(user()->getOption('passport_id')),
|
||||
])
|
||||
->columnSpan(3)
|
||||
->label(__('Passport serie and number'))
|
||||
@@ -171,37 +180,43 @@ class LoanOrderForm
|
||||
->native(false)
|
||||
->closeOnDateSelection()
|
||||
->beforeOrEqual('today')
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('passport_given_at')),
|
||||
|
||||
TextInput::make('born_place')
|
||||
->columnSpan(3)
|
||||
->label(__('Born place (passport)'))
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('born_place')),
|
||||
|
||||
TextInput::make('passport_given_by')
|
||||
->label(__('Passport given by'))
|
||||
->columnSpan(4)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('passport_given_by')),
|
||||
|
||||
TextInput::make('passport_address')
|
||||
->columnSpan(4)
|
||||
->label(__('Proscription for home'))
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('passport_address')),
|
||||
|
||||
TextInput::make('real_address')
|
||||
->label(__('Current home address'))
|
||||
->columnSpan(4)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('real_address')),
|
||||
|
||||
TextInput::make('email')
|
||||
->label(__('Email'))
|
||||
->email()
|
||||
->maxLength(255)
|
||||
->columnSpan(2),
|
||||
->columnSpan(2)
|
||||
->default(user()->getOption('email')),
|
||||
|
||||
TextInput::make('phone')
|
||||
->label(__('Phone'))
|
||||
@@ -211,7 +226,8 @@ class LoanOrderForm
|
||||
->rules([
|
||||
new PhoneNumberVerificationRule,
|
||||
])
|
||||
->columnSpan(2),
|
||||
->columnSpan(2)
|
||||
->default(user()->phone),
|
||||
|
||||
TextInput::make('phone_additional')
|
||||
->label(__('Additional phone'))
|
||||
@@ -281,12 +297,14 @@ class LoanOrderForm
|
||||
->options(RegionRepository::values())
|
||||
->columnSpan(1)
|
||||
->live()
|
||||
->afterStateUpdated(fn (callable $set) => $set('branch_id', null))
|
||||
->afterStateUpdated(fn (callable $set) => $set('work_province_id', null))
|
||||
->required(),
|
||||
|
||||
Select::make('work_province_id')
|
||||
->label(__('Work province'))
|
||||
->relationship('workProvince', 'name', function ($query, callable $get) {
|
||||
$query->orderByTranslation('name');
|
||||
|
||||
$region = $get('work_region');
|
||||
if ($region) {
|
||||
$query->where('region', $region);
|
||||
|
||||
@@ -23,17 +23,17 @@ class LoanOrdersTable
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('loanType.name')
|
||||
->label('Тип кредита')
|
||||
->label(__('Loan type'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('region')
|
||||
->label('Регион')
|
||||
->label(__('Region'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('branch.name')
|
||||
->label('Филиал')
|
||||
->label(__('Branch'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user