loan orders
This commit is contained in:
@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Log;
|
||||
class OnlinePaymentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Online pa
|
||||
* Online payment
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Loan\LoanOrder;
|
||||
use App\Modules\LoanOrder\Controllers\Requests\LoanOrderStoreRequest;
|
||||
use App\Modules\LoanOrder\Controllers\Resources\LoanOrderIndexResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoanOrderController extends Controller
|
||||
@@ -13,7 +14,7 @@ class LoanOrderController extends Controller
|
||||
/**
|
||||
* LIST* Loan orders.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json(LoanOrderIndexResource::collection(
|
||||
LoanOrder::query()->where('user_id', auth()->id())->paginate()
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Repos\System\Nova\NovaRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Ebess\AdvancedNovaMediaLibrary\Fields\Files;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Nova\Fields\Badge;
|
||||
@@ -60,6 +61,27 @@ class NovaVisaMasterPaymentOrder extends Resource
|
||||
*/
|
||||
public static $with = ['branch'];
|
||||
|
||||
/**
|
||||
* Indicates whether the resource should automatically poll for new resources.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $polling = true;
|
||||
|
||||
/**
|
||||
* The interval at which Nova should poll for new resources.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public static $pollingInterval = 120;
|
||||
|
||||
/**
|
||||
* Indicates whether to show the polling toggle button inside Nova.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $showPollingToggle = true;
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
@@ -84,6 +106,27 @@ class NovaVisaMasterPaymentOrder extends Resource
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an "index" query for the given resource.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public static function indexQuery(NovaRequest $request, mixed $query): Builder
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if ($user->isOperator()) {
|
||||
return $query->whereIn('branch_id', $user->branches()->pluck('branches.id'));
|
||||
}
|
||||
|
||||
return $query->where('user_id', $request->user()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* After resource created
|
||||
*
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Nova\Resources\Order\Loan\Concerns;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Loan\LoanType;
|
||||
use App\Nova\Resources\System\Location\Province;
|
||||
use App\Nova\User;
|
||||
use App\Repos\Order\Loan\LoanTypeRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Legal\EducationRepo;
|
||||
use App\Repos\System\Settings\Legal\MarriageRepo;
|
||||
@@ -17,6 +19,7 @@ use Laravel\Nova\Fields\DateTime;
|
||||
use Laravel\Nova\Fields\Email;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Image;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Panel;
|
||||
@@ -51,6 +54,7 @@ class LoanOrderFieldsForDetail
|
||||
|
||||
new Panel(__('Loan'), [
|
||||
BelongsTo::make(__('Loan type'), 'loanType', LoanType::class),
|
||||
Number::make(__('Amount of loan'), 'loan_amount'),
|
||||
]),
|
||||
|
||||
new Panel(__('Location'), [
|
||||
@@ -89,6 +93,22 @@ class LoanOrderFieldsForDetail
|
||||
->size('w-1/2'),
|
||||
]),
|
||||
|
||||
new Panel(__('Card'), [
|
||||
Number::make(__('Card number'), 'card_number'),
|
||||
|
||||
Text::make(__('Name on card'), 'card_name'),
|
||||
|
||||
Select::make(__('Expiration month'), 'card_month')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::monthsAsNumber()),
|
||||
|
||||
Select::make(__('Expiration year'), 'card_year')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::yearsUntil()),
|
||||
]),
|
||||
|
||||
new Panel(__('Contact data'), [
|
||||
Email::make(__('Email'), 'email')
|
||||
->size('w-1/4'),
|
||||
@@ -161,6 +181,47 @@ class LoanOrderFieldsForDetail
|
||||
Image::make(__('Passport (page 32)'), 'passport_four')
|
||||
->size('w-1/2'),
|
||||
]),
|
||||
|
||||
new Panel(__('1. Guarantor'), [
|
||||
Text::make(__('Guarantor name'), 'guarantor_name'),
|
||||
|
||||
Text::make(__('Guarantor Surname'), 'guarantor_surname'),
|
||||
|
||||
Text::make(__('Guarantor Patronic name'), 'guarantor_patronic_name'),
|
||||
|
||||
Number::make(__('Card number'), 'guarantor_card_number'),
|
||||
|
||||
Text::make(__('Name on card'), 'guarantor_card_name'),
|
||||
|
||||
Select::make(__('Expiration month'), 'guarantor_card_month')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::monthsAsNumber()),
|
||||
|
||||
Select::make(__('Expiration year'), 'guarantor_card_year')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::yearsUntil()),
|
||||
]),
|
||||
|
||||
new Panel(__('2. Guarantor'), [
|
||||
Text::make(__('Guarantor name'), 'guarantor_2_name'),
|
||||
Text::make(__('Guarantor Surname'), 'guarantor_2_surname'),
|
||||
Text::make(__('Guarantor Patronic name'), 'guarantor_2_patronic_name'),
|
||||
|
||||
Number::make(__('Card number'), 'guarantor_2_card_number'),
|
||||
Text::make(__('Name on card'), 'guarantor_2_card_name'),
|
||||
|
||||
Select::make(__('Expiration month'), 'guarantor_2_card_month')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::monthsAsNumber()),
|
||||
|
||||
Select::make(__('Expiration year'), 'guarantor_2_card_year')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::yearsUntil()),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Nova\Resources\Order\Loan;
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Loan\LoanOrder as LoanOrderModel;
|
||||
use App\Models\System\Location\Province;
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Resource;
|
||||
@@ -176,6 +177,15 @@ class LoanOrder extends Resource
|
||||
->options(LoanTypeRepo::values())
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
|
||||
Number::make(__('Amount of loan'), 'loan_amount')
|
||||
->hide()
|
||||
->fullWidth()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type === LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required', 'integer', 'max:40000');
|
||||
}
|
||||
}),
|
||||
]),
|
||||
|
||||
new Panel(__('Location'), [
|
||||
@@ -241,6 +251,50 @@ class LoanOrder extends Resource
|
||||
->rules('required', 'string', new DowranAgaAllowed, 'max:255'),
|
||||
]),
|
||||
|
||||
new Panel(__('Card'), [
|
||||
Number::make(__('Card number'), 'card_number')
|
||||
->size('w-1/4')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
|
||||
Text::make(__('Name on card'), 'card_name')
|
||||
->size('w-1/4')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
|
||||
Select::make(__('Expiration month'), 'card_month')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::monthsAsNumber())
|
||||
->size('w-1/4')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
|
||||
Select::make(__('Expiration year'), 'card_year')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::yearsUntil())
|
||||
->size('w-1/4')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
]),
|
||||
|
||||
new Panel(__('Passport'), [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
@@ -359,6 +413,157 @@ class LoanOrder extends Resource
|
||||
->creationRules('required')
|
||||
->updateRules('nullable'),
|
||||
]),
|
||||
|
||||
new Panel(__('1. Guarantor'), [
|
||||
Text::make(__('Guarantor name'), 'guarantor_name')
|
||||
->fullWidth()
|
||||
->size('w-1/3')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Text::make(__('Guarantor Surname'), 'guarantor_surname')
|
||||
->fullWidth()
|
||||
->size('w-1/3')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Text::make(__('Guarantor Patronic name'), 'guarantor_patronic_name')
|
||||
->fullWidth()
|
||||
->size('w-1/3')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('nullable', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Number::make(__('Card number'), 'guarantor_card_number')
|
||||
->size('w-1/2')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required', 'integer', 'digits:16');
|
||||
}
|
||||
}),
|
||||
|
||||
Text::make(__('Name on card'), 'guarantor_card_name')
|
||||
->size('w-1/2')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Select::make(__('Expiration month'), 'guarantor_card_month')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::monthsAsNumber())
|
||||
->size('w-1/2')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
|
||||
Select::make(__('Expiration year'), 'guarantor_card_year')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::yearsUntil())
|
||||
->size('w-1/2')
|
||||
->hide()
|
||||
->dependsOn('loan_type', function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId()) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
]),
|
||||
|
||||
new Panel(__('2. Guarantor'), [
|
||||
Text::make(__('Guarantor name'), 'guarantor_2_name')
|
||||
->fullWidth()
|
||||
->size('w-1/3')
|
||||
->hide()
|
||||
->dependsOn(['loan_type', 'loan_amount'], function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId() && $formData->loan_amount && floatval($formData->loan_amount) > 20000) {
|
||||
$field->show()->rules('required', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Text::make(__('Guarantor Surname'), 'guarantor_2_surname')
|
||||
->fullWidth()
|
||||
->size('w-1/3')
|
||||
->hide()
|
||||
->dependsOn(['loan_type', 'loan_amount'], function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId() && $formData->loan_amount && floatval($formData->loan_amount) > 20000) {
|
||||
$field->show()->rules('required', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Text::make(__('Guarantor Patronic name'), 'guarantor_2_patronic_name')
|
||||
->fullWidth()
|
||||
->size('w-1/3')
|
||||
->hide()
|
||||
->dependsOn(['loan_type', 'loan_amount'], function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId() && $formData->loan_amount && floatval($formData->loan_amount) > 20000) {
|
||||
$field->show()->rules('nullable', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Number::make(__('Card number'), 'guarantor_2_card_number')
|
||||
->size('w-1/2')
|
||||
->hide()
|
||||
->dependsOn(['loan_type', 'loan_amount'], function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId() && $formData->loan_amount && floatval($formData->loan_amount) > 20000) {
|
||||
$field->show()->rules('nullable', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Text::make(__('Name on card'), 'guarantor_2_card_name')
|
||||
->size('w-1/2')
|
||||
->hide()
|
||||
->dependsOn(['loan_type', 'loan_amount'], function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId() && $formData->loan_amount && floatval($formData->loan_amount) > 20000) {
|
||||
$field->show()->rules('required', 'string', 'max:255');
|
||||
}
|
||||
}),
|
||||
|
||||
Select::make(__('Expiration month'), 'guarantor_2_card_month')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::monthsAsNumber())
|
||||
->size('w-1/2')
|
||||
->sortable()
|
||||
->hide()
|
||||
->dependsOn(['loan_type', 'loan_amount'], function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId() && $formData->loan_amount && floatval($formData->loan_amount) > 20000) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
|
||||
Select::make(__('Expiration year'), 'guarantor_2_card_year')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(DateHelperRepository::yearsUntil())
|
||||
->size('w-1/2')
|
||||
->sortable()
|
||||
->hide()
|
||||
->dependsOn(['loan_type', 'loan_amount'], function ($field, $request, $formData) {
|
||||
if ($formData->loan_type == LoanTypeRepo::loanTypeGuarantorId() && $formData->loan_amount && floatval($formData->loan_amount) > 20000) {
|
||||
$field->show()->rules('required');
|
||||
}
|
||||
}),
|
||||
]),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -16,4 +16,12 @@ class LoanTypeRepo
|
||||
{
|
||||
return LoanType::where('active', true)->pluck('name', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loan type guarantor id
|
||||
*/
|
||||
public static function loanTypeGuarantorId(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user