diff --git a/app/Modules/BaseAppEnum/Controllers/BaseAppEnumController.php b/app/Modules/BaseAppEnum/Controllers/BaseAppEnumController.php index 4a3fb0f..4ca49fe 100644 --- a/app/Modules/BaseAppEnum/Controllers/BaseAppEnumController.php +++ b/app/Modules/BaseAppEnum/Controllers/BaseAppEnumController.php @@ -14,14 +14,23 @@ class BaseAppEnumController extends Controller /** * Base app enums */ - public function index() + public function index(): array { return [ 'loan_types' => LoanTypeRepo::onlyGuarantor(), 'regions' => RegionRepo::values(), - 'educations' => EducationRepo::values(), + 'educations' => $this->educationValues(), 'marriage_statuses' => MarriageRepo::values(), 'passport_series' => PassportRepo::values(), ]; } + + public function educationValues(): array + { + return [ + EducationRepo::MIDDLE_SCHOOL => __('Middle school'), + EducationRepo::UNFINISHED_HIGH_EDUCATION => __('Unfinished high education'), + EducationRepo::HIGH_EDUCATION => __('High education'), + ]; + } } diff --git a/app/Nova/Resources/Order/Loan/LoanOrderMobile.php b/app/Nova/Resources/Order/Loan/LoanOrderMobile.php index 99148a8..002f725 100644 --- a/app/Nova/Resources/Order/Loan/LoanOrderMobile.php +++ b/app/Nova/Resources/Order/Loan/LoanOrderMobile.php @@ -10,6 +10,7 @@ use App\Nova\Filters\RegionFilter; use App\Nova\Filters\StatusFilter; use App\Nova\Resource; use App\Nova\Resources\Order\Loan\Concerns\LoanOrderFieldsForIndex; +use App\Repos\Order\Loan\LoanOrderRepo; use App\Repos\Order\Loan\LoanTypeRepo; use App\Repos\Order\OrderRepo; use App\Repos\System\Nova\NovaRepo; @@ -140,7 +141,7 @@ class LoanOrderMobile extends Resource */ public function fieldsForDetail(): array { - return LoanOrderMobileFieldsForDetail::make(); + return LoanOrderMobileFieldsForDetail::make($this); } /** @@ -248,6 +249,12 @@ class LoanOrderMobile extends Resource Text::make(__('Current Residence'), 'real_address') ->size('w-1/2') ->rules('required', 'string', new DowranAgaAllowed, 'max:255'), + + Select::make(__('Karz taryhy'), 'satisfiable') + ->searchable() + ->displayUsingLabels() + ->options(LoanOrderRepo::satisfiableValues()) + ->size('w-full'), ]), new Panel(__('Card'), [ @@ -430,6 +437,10 @@ class LoanOrderMobile extends Resource ->options(DateHelperRepository::yearsUntil()) ->size('w-1/2') ->rules('required'), + + Text::make(__('Ortaça zähmen haky'), 'guarantor_note') + ->size('w-full') + ->canSeeWhen('systemUser', $this), ]), new Panel('2. '.__('Guarantor'), [ @@ -506,6 +517,16 @@ class LoanOrderMobile extends Resource $field->show()->rules('required'); } }), + + Text::make(__('Ortaça zähmen haky'), 'guarantor_2_note') + ->size('w-full') + ->hide() + ->canSeeWhen('systemUser', $this) + ->dependsOn('loan_amount', function ($field, $request, $formData) { + if ($formData->loan_amount && floatval($formData->loan_amount) > 20000) { + $field->show()->rules('required'); + } + }), ]), ]; diff --git a/app/Nova/Resources/Order/Loan/LoanOrderMobileFieldsForDetail.php b/app/Nova/Resources/Order/Loan/LoanOrderMobileFieldsForDetail.php index 53f1f8d..deec497 100644 --- a/app/Nova/Resources/Order/Loan/LoanOrderMobileFieldsForDetail.php +++ b/app/Nova/Resources/Order/Loan/LoanOrderMobileFieldsForDetail.php @@ -6,6 +6,7 @@ use App\Modules\DateHelper\Repositories\DateHelperRepository; use App\Nova\Resources\Branch\Branch; use App\Nova\Resources\System\Location\Province; use App\Nova\User; +use App\Repos\Order\Loan\LoanOrderRepo; use App\Repos\Order\OrderRepo; use App\Repos\System\Settings\Legal\EducationRepo; use App\Repos\System\Settings\Legal\MarriageRepo; @@ -25,7 +26,7 @@ use Nurmuhammet\NovaInputmask\NovaInputmask; class LoanOrderMobileFieldsForDetail { - public static function make(): array + public static function make($resource): array { return [ ID::make()->hide(), @@ -69,23 +70,22 @@ class LoanOrderMobileFieldsForDetail Select::make(__('Education'), 'education') ->displayUsingLabels() - ->options(EducationRepo::values()) - ->size('w-1/3'), + ->options(EducationRepo::values()), Select::make(__('Marriage status'), 'marriage_status') ->displayUsingLabels() - ->options(MarriageRepo::values()) - ->size('w-1/3'), + ->options(MarriageRepo::values()), Date::make(__('Date of birth'), 'born_at') - ->size('w-1/3') ->toTurkmenFormat(), - Text::make(__('Residence (passport)'), 'passport_address') - ->size('w-1/2'), + Text::make(__('Residence (passport)'), 'passport_address'), - Text::make(__('Current Residence'), 'real_address') - ->size('w-1/2'), + Text::make(__('Current Residence'), 'real_address'), + + Select::make(__('Karz taryhy'), 'satisfiable') + ->displayUsingLabels() + ->options(LoanOrderRepo::satisfiableValues()), ]), new Panel(__('Card'), [ @@ -197,6 +197,9 @@ class LoanOrderMobileFieldsForDetail ->displayUsingLabels() ->searchable() ->options(DateHelperRepository::yearsUntil()), + + Text::make(__('Ortaça zähmen haky'), 'guarantor_note') + ->canSeeWhen('systemUser', $resource), ]), new Panel('2. '.__('Guarantor'), [ @@ -216,6 +219,9 @@ class LoanOrderMobileFieldsForDetail ->displayUsingLabels() ->searchable() ->options(DateHelperRepository::yearsUntil()), + + Text::make(__('Ortaça zähmen haky'), 'guarantor_2_note') + ->canSeeWhen('systemUser', $resource), ]), ]; diff --git a/app/Repos/Order/Loan/LoanOrderRepo.php b/app/Repos/Order/Loan/LoanOrderRepo.php index 1d57130..8f3b4d8 100644 --- a/app/Repos/Order/Loan/LoanOrderRepo.php +++ b/app/Repos/Order/Loan/LoanOrderRepo.php @@ -9,6 +9,16 @@ use Illuminate\Database\Eloquent\Model; class LoanOrderRepo { + public static function satisfiableValues(): array + { + return [ + null => '-', + 'satisfiable' => __('Satisfiable'), + 'insufficient' => __('Insufficient'), + 'unknown' => __('Unknown'), + ]; + } + /** * When model is being created */ diff --git a/database/migrations/2024_09_26_023233_add_guarantor_notes_for_laon_orders_table.php b/database/migrations/2024_09_26_023233_add_guarantor_notes_for_laon_orders_table.php new file mode 100644 index 0000000..a45ef74 --- /dev/null +++ b/database/migrations/2024_09_26_023233_add_guarantor_notes_for_laon_orders_table.php @@ -0,0 +1,30 @@ +string('guarantor_note')->nullable(); + $table->string('guarantor_2_note')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('loan_orders', function (Blueprint $table) { + $table->dropColumn('guarantor_note'); + $table->dropColumn('guarantor_2_note'); + }); + } +}; diff --git a/database/migrations/2024_09_26_023939_add_loan_order_history_statisfiable.php b/database/migrations/2024_09_26_023939_add_loan_order_history_statisfiable.php new file mode 100644 index 0000000..9c1ac2e --- /dev/null +++ b/database/migrations/2024_09_26_023939_add_loan_order_history_statisfiable.php @@ -0,0 +1,28 @@ +string('satisfiable')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('loan_orders', function (Blueprint $table) { + $table->dropColumn('satisfiable'); + }); + } +}; diff --git a/lang/tk.json b/lang/tk.json index d4846f4..c09bbc6 100644 --- a/lang/tk.json +++ b/lang/tk.json @@ -310,5 +310,8 @@ "Guarantor": "Zamun", "Guarantor name": "Zamunyň ady", "Guarantor Surname": "Zamunyň familiýasy", - "Guarantor Patronic name": "Zamunyň atasynyň ady" + "Guarantor Patronic name": "Zamunyň atasynyň ady", + "Satisfiable": "Kanagatlanarly", + "Insufficient": "Kanagatlanarsyz", + "Unknown": "Näbelli" }