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