From 8b87f58a0cfe3786109ab3fb20932c8388e6a240 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Tue, 26 Nov 2024 01:37:59 +0500 Subject: [PATCH] loan remaining added --- app/Http/Controllers/AlertController.php | 4 +- app/Models/Alert.php | 2 +- app/Models/Order/Loan/LoanOrder.php | 1 - .../LoanRemainingOrderController.php | 49 +++++++ ...11830_create_loanremainingorders_table.php | 30 +++++ .../Models/LoanRemainingOrder.php | 10 ++ .../LoanRemainingOrderRepository.php | 5 + .../Loan/Remaining/NovaLoanRemainingOrder.php | 126 ++++++++++++++++++ app/Repos/System/Nova/NovaMenuRepo.php | 2 + 9 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 app/Modules/LoanRemainingOrder/Controllers/LoanRemainingOrderController.php create mode 100644 app/Modules/LoanRemainingOrder/Database/Migrations/2024_11_26_011830_create_loanremainingorders_table.php create mode 100644 app/Modules/LoanRemainingOrder/Models/LoanRemainingOrder.php create mode 100644 app/Modules/LoanRemainingOrder/Repositories/LoanRemainingOrderRepository.php create mode 100644 app/Nova/Resources/Order/Loan/Remaining/NovaLoanRemainingOrder.php diff --git a/app/Http/Controllers/AlertController.php b/app/Http/Controllers/AlertController.php index 50df2cc..159d9f3 100644 --- a/app/Http/Controllers/AlertController.php +++ b/app/Http/Controllers/AlertController.php @@ -2,8 +2,6 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; - class AlertController extends Controller { /** @@ -16,7 +14,7 @@ class AlertController extends Controller $alerts = $alerstQuery->get(); $alerstQuery->update([ - 'seen_at' => now() + 'seen_at' => now(), ]); return response()->json($this->format($alerts)); diff --git a/app/Models/Alert.php b/app/Models/Alert.php index 8e75be9..88e1d23 100644 --- a/app/Models/Alert.php +++ b/app/Models/Alert.php @@ -14,7 +14,7 @@ class Alert extends Model * Casts */ protected $casts = [ - 'seen_at' => 'datetime' + 'seen_at' => 'datetime', ]; /** diff --git a/app/Models/Order/Loan/LoanOrder.php b/app/Models/Order/Loan/LoanOrder.php index fe6c892..82177a8 100644 --- a/app/Models/Order/Loan/LoanOrder.php +++ b/app/Models/Order/Loan/LoanOrder.php @@ -197,7 +197,6 @@ class LoanOrder extends Model static::creating(LoanOrderRepo::creating()); static::created(LoanOrderRepo::created()); static::updated(function (LoanOrder $model) { - info($model->notes); if ($model->notes && $model->wasChanged('notes')) { auth()->user()->alerts()->create([ 'name' => 'Duýdyryş', diff --git a/app/Modules/LoanRemainingOrder/Controllers/LoanRemainingOrderController.php b/app/Modules/LoanRemainingOrder/Controllers/LoanRemainingOrderController.php new file mode 100644 index 0000000..a6eb11e --- /dev/null +++ b/app/Modules/LoanRemainingOrder/Controllers/LoanRemainingOrderController.php @@ -0,0 +1,49 @@ +id(); + $table->string('passport_serie')->index(); + $table->string('passport_id')->index(); + $table->string('account_number')->index(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('loan_remaining_orders'); + } +}; diff --git a/app/Modules/LoanRemainingOrder/Models/LoanRemainingOrder.php b/app/Modules/LoanRemainingOrder/Models/LoanRemainingOrder.php new file mode 100644 index 0000000..1774bbc --- /dev/null +++ b/app/Modules/LoanRemainingOrder/Models/LoanRemainingOrder.php @@ -0,0 +1,10 @@ + + */ + public static $model = \App\Modules\LoanRemainingOrder\Models\LoanRemainingOrder::class; + + /** + * The single value that should be used to represent the resource when being displayed. + * + * @var string + */ + public static $title = 'account_number'; + + /** + * The columns that should be searched. + * + * @var array + */ + public static $search = [ + 'account_number' + ]; + + /** + * Get the displayable label of the resource. + */ + public static function label(): string + { + return __('Karzyň galyndysy'); + } + + /** + * Get the fields displayed by the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function fields(NovaRequest $request) + { + return [ + ID::make()->sortable(), + + Select::make(__('Passport serie'), 'passport_serie') + ->displayUsingLabels() + ->searchable() + ->options(PassportRepo::values()) + ->rules('required') + ->sortable(), + + Number::make(__('Passport id'), 'passport_id') + ->rules('required', 'numeric', 'digits:6'), + + Text::make(__('Karz hasaby'), 'account_number') + ->rules('required'), + + new Panel(__('Karz taryhy'), [ + NovaCustomHtml::make(__('Karz taryhy'), 'loan_history') + ->canSeeWhen('systemUser', $this) + ->html(view('orders.loan.mobile.loan-history', [ + 'resource' => $this, + ])->render()), + ]), + ]; + } + + /** + * Get the cards available for the request. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function cards(NovaRequest $request) + { + return []; + } + + /** + * Get the filters available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function filters(NovaRequest $request) + { + return []; + } + + /** + * Get the lenses available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function lenses(NovaRequest $request) + { + return []; + } + + /** + * Get the actions available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function actions(NovaRequest $request) + { + return []; + } +} diff --git a/app/Repos/System/Nova/NovaMenuRepo.php b/app/Repos/System/Nova/NovaMenuRepo.php index 1eccdde..858758e 100644 --- a/app/Repos/System/Nova/NovaMenuRepo.php +++ b/app/Repos/System/Nova/NovaMenuRepo.php @@ -18,6 +18,7 @@ use App\Nova\Resources\Order\Loan\LoanOrder; use App\Nova\Resources\Order\Loan\LoanOrderMobile; use App\Nova\Resources\Order\Loan\LoanPaidOffLetterOrder; use App\Nova\Resources\Order\Loan\LoanType; +use App\Nova\Resources\Order\Loan\Remaining\NovaLoanRemainingOrder; use App\Nova\Resources\Order\Loan\RequiredDocs\LoanOrderRequiredDocs; use App\Nova\Resources\Payment\OnlinePaymentHistoryResource; use App\Nova\Resources\System\Locale\LocaleManagerResource; @@ -49,6 +50,7 @@ class NovaMenuRepo MenuItem::resource(LoanOrder::class), MenuItem::resource(LoanOrderMobile::class) ->name(__('Loan order').' (Mobile)'), + MenuItem::resource(NovaLoanRemainingOrder::class), MenuItem::resource(LoanPaidOffLetterOrder::class), ])->collapsedByDefault(),