From 5e35dd6a1139b9de1a41c29aa1b1e5435cfe17df Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Thu, 23 Nov 2023 18:28:24 +0500 Subject: [PATCH] working on loan orders --- app/Models/Branch/Branch.php | 1 + app/Models/Order/Loan/LoanOrder.php | 13 ++ app/Models/Order/Loan/LoanType.php | 33 ++++++ app/Models/System/Location/Province.php | 1 + app/Nova/Resources/Branch/Branch.php | 4 + app/Nova/Resources/Order/Loan/LoanType.php | 111 ++++++++++++++++++ .../Resources/System/Location/Province.php | 6 +- app/Providers/NovaServiceProvider.php | 6 +- composer.json | 3 +- composer.lock | 48 +++++++- ...23_11_23_143516_create_provinces_table.php | 1 + ...023_11_23_143517_create_branches_table.php | 3 +- ...3_11_23_162919_create_loan_types_table.php | 32 +++++ ..._11_23_162920_create_loan_orders_table.php | 79 +++++++++++++ 14 files changed, 336 insertions(+), 5 deletions(-) create mode 100644 app/Models/Order/Loan/LoanOrder.php create mode 100644 app/Models/Order/Loan/LoanType.php create mode 100644 app/Nova/Resources/Order/Loan/LoanType.php create mode 100644 database/migrations/2023_11_23_162919_create_loan_types_table.php create mode 100644 database/migrations/2023_11_23_162920_create_loan_orders_table.php diff --git a/app/Models/Branch/Branch.php b/app/Models/Branch/Branch.php index d6b76d9..484939e 100644 --- a/app/Models/Branch/Branch.php +++ b/app/Models/Branch/Branch.php @@ -31,6 +31,7 @@ class Branch extends Model 'billing_username', 'billing_password', 'address', + 'active', ]; /** diff --git a/app/Models/Order/Loan/LoanOrder.php b/app/Models/Order/Loan/LoanOrder.php new file mode 100644 index 0000000..24411b8 --- /dev/null +++ b/app/Models/Order/Loan/LoanOrder.php @@ -0,0 +1,13 @@ + + */ + protected $fillable = [ + 'name', + 'tax', + 'maturity', + 'notes', + 'active', + ]; + + /** + * Translatable fields + * + * @var array + */ + public $translatable = ['name', 'notes']; +} diff --git a/app/Models/System/Location/Province.php b/app/Models/System/Location/Province.php index 89cb564..35c0a8d 100644 --- a/app/Models/System/Location/Province.php +++ b/app/Models/System/Location/Province.php @@ -19,6 +19,7 @@ class Province extends Model protected $fillable = [ 'region', 'name', + 'active', ]; /** diff --git a/app/Nova/Resources/Branch/Branch.php b/app/Nova/Resources/Branch/Branch.php index a006d51..634b686 100644 --- a/app/Nova/Resources/Branch/Branch.php +++ b/app/Nova/Resources/Branch/Branch.php @@ -12,6 +12,7 @@ use Laravel\Nova\Fields\Text; use Laravel\Nova\Fields\Textarea; use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Resource; +use Trin4ik\NovaSwitcher\NovaSwitcher; class Branch extends Resource { @@ -89,6 +90,9 @@ class Branch extends Resource ->rules('nullable', 'string', 'max:255'), Textarea::make(__('Address'), 'address'), + + NovaSwitcher::make(__('Active'), 'active') + ->default(true), ]; } diff --git a/app/Nova/Resources/Order/Loan/LoanType.php b/app/Nova/Resources/Order/Loan/LoanType.php new file mode 100644 index 0000000..325dfb4 --- /dev/null +++ b/app/Nova/Resources/Order/Loan/LoanType.php @@ -0,0 +1,111 @@ + + */ + public static $model = LoanTypeModel::class; + + /** + * The single value that should be used to represent the resource when being displayed. + * + * @var string + */ + public static $title = 'name'; + + /** + * The columns that should be searched. + * + * @var array + */ + public static $search = [ + 'name', + ]; + + /** + * Get the fields displayed by the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function fields(NovaRequest $request): array + { + return [ + ID::make()->sortable(), + + Text::make(__('Name'), 'name') + ->rules('required', 'string', 'max:255') + ->translatable(), + + Number::make(__('Tax'), 'tax') + ->rules('required', 'numeric', 'max:100'), + + Text::make(__('Maturity'), 'maturity') + ->rules('required', 'string', 'max:255'), + + Text::make(__('Notes'), 'notes') + ->rules('required', 'string', 'max:255'), + + NovaSwitcher::make(__('Active'), 'active') + ->default(true), + ]; + } + + /** + * Get the cards available for the request. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function cards(NovaRequest $request): array + { + return []; + } + + /** + * Get the filters available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function filters(NovaRequest $request): array + { + return []; + } + + /** + * Get the lenses available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function lenses(NovaRequest $request): array + { + return []; + } + + /** + * Get the actions available for the resource. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function actions(NovaRequest $request): array + { + return []; + } +} diff --git a/app/Nova/Resources/System/Location/Province.php b/app/Nova/Resources/System/Location/Province.php index 02f818e..3e12bea 100644 --- a/app/Nova/Resources/System/Location/Province.php +++ b/app/Nova/Resources/System/Location/Province.php @@ -10,6 +10,7 @@ use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; +use Trin4ik\NovaSwitcher\NovaSwitcher; class Province extends Resource { @@ -25,7 +26,7 @@ class Province extends Resource * * @var string */ - public static $title = 'id'; + public static $title = 'name'; /** * The columns that should be searched. @@ -70,6 +71,9 @@ class Province extends Resource Text::make(__('Name'), 'name') ->rules('required', 'string', 'max:255'), + + NovaSwitcher::make(__('Active'), 'active') + ->default(true), ]; } diff --git a/app/Providers/NovaServiceProvider.php b/app/Providers/NovaServiceProvider.php index f336c3e..9e6ac98 100644 --- a/app/Providers/NovaServiceProvider.php +++ b/app/Providers/NovaServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use App\Nova\Resources\Branch\Branch; +use App\Nova\Resources\Order\Loan\LoanType; use App\Nova\Resources\System\Location\Province; use App\Nova\Resources\System\Roles\Permission; use App\Nova\Resources\System\Roles\Role; @@ -117,11 +118,14 @@ class NovaServiceProvider extends NovaApplicationServiceProvider MenuItem::resource(Permission::class), ])->collapsable(), + MenuGroup::make(__('Loans'), [ + MenuItem::resource(LoanType::class), + ])->collapsable(), + MenuGroup::make(__('Location'), [ MenuItem::resource(Province::class), MenuItem::resource(Branch::class), ])->collapsable(), - ])->icon('cog')->collapsable(), ]; }); diff --git a/composer.json b/composer.json index a0ea469..ba80ed7 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "laravel/tinker": "^2.8", "outl1ne/nova-translatable": "^2.2", "spatie/laravel-permission": "^6.1", - "spatie/laravel-translatable": "^6.5" + "spatie/laravel-translatable": "^6.5", + "trin4ik/nova-switcher": "^0.4.0" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/composer.lock b/composer.lock index ae9fdb3..8396818 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "db74e81011c0c297cac0a68bbe058ea3", + "content-hash": "09947809353f3e7cb6ef72488a67a75d", "packages": [ { "name": "brick/math", @@ -6765,6 +6765,52 @@ }, "time": "2023-01-03T09:29:04+00:00" }, + { + "name": "trin4ik/nova-switcher", + "version": "v0.4", + "source": { + "type": "git", + "url": "https://github.com/trin4ik/nova-switcher.git", + "reference": "06b7dc8cbe842bf0943c161f9335546dbe6dd30c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/trin4ik/nova-switcher/zipball/06b7dc8cbe842bf0943c161f9335546dbe6dd30c", + "reference": "06b7dc8cbe842bf0943c161f9335546dbe6dd30c", + "shasum": "" + }, + "require": { + "laravel/nova": "^4.0", + "php": "^8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Trin4ik\\NovaSwitcher\\FieldServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Trin4ik\\NovaSwitcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A Laravel Nova switcher field.", + "keywords": [ + "laravel", + "nova" + ], + "support": { + "issues": "https://github.com/trin4ik/nova-switcher/issues", + "source": "https://github.com/trin4ik/nova-switcher/tree/v0.4" + }, + "time": "2023-11-01T05:33:29+00:00" + }, { "name": "vlucas/phpdotenv", "version": "v5.6.0", diff --git a/database/migrations/2023_11_23_143516_create_provinces_table.php b/database/migrations/2023_11_23_143516_create_provinces_table.php index 5bf2f49..6367c74 100644 --- a/database/migrations/2023_11_23_143516_create_provinces_table.php +++ b/database/migrations/2023_11_23_143516_create_provinces_table.php @@ -15,6 +15,7 @@ return new class extends Migration $table->id(); $table->string('region', 2)->index(); $table->jsonb('name'); + $table->boolean('active')->default(true); $table->timestamps(); }); } diff --git a/database/migrations/2023_11_23_143517_create_branches_table.php b/database/migrations/2023_11_23_143517_create_branches_table.php index 1386735..128bea4 100644 --- a/database/migrations/2023_11_23_143517_create_branches_table.php +++ b/database/migrations/2023_11_23_143517_create_branches_table.php @@ -18,10 +18,11 @@ return new class extends Migration $table->string('unique_code')->index()->nullable(); $table->string('region', 2)->index(); - $table->foreignId('province_id')->nullable()->constrained()->nullOnDelete(); + $table->foreignId('province_id')->nullable()->constrained()->restrictOnDelete(); $table->string('billing_username')->nullable(); $table->string('billing_password')->nullable(); + $table->boolean('active')->default(true); $table->timestamps(); }); } diff --git a/database/migrations/2023_11_23_162919_create_loan_types_table.php b/database/migrations/2023_11_23_162919_create_loan_types_table.php new file mode 100644 index 0000000..391524a --- /dev/null +++ b/database/migrations/2023_11_23_162919_create_loan_types_table.php @@ -0,0 +1,32 @@ +id(); + $table->jsonb('name'); + $table->string('tax')->nullable(); + $table->string('maturity')->nullable(); + $table->string('notes')->nullable(); + $table->boolean('active')->default(true); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('loan_orders'); + } +}; diff --git a/database/migrations/2023_11_23_162920_create_loan_orders_table.php b/database/migrations/2023_11_23_162920_create_loan_orders_table.php new file mode 100644 index 0000000..0af567f --- /dev/null +++ b/database/migrations/2023_11_23_162920_create_loan_orders_table.php @@ -0,0 +1,79 @@ +id(); + $table->string('unique_id')->unique(); + + $table->foreignId('loan_type')->constrained()->restrictOnDelete(); + + $table->string('region', 2)->index(); + $table->foreignId('branch_id')->constrained()->restrictOnDelete(); + + $table->string('customer_name')->index(); + $table->string('customer_surname')->index(); + $table->string('customer_patronic_name')->nullable(); + + $table->string('passport_address'); + $table->string('real_address'); + + $table->string('passport_serie')->index(); + $table->integer('passport_id')->index(); + $table->date('passport_given_at'); + $table->string('passport_given_by'); + + $table->string('born_place'); + $table->date('born_at'); + + $table->string('email')->nullable()->index(); + $table->string('phone')->index(); + $table->string('phone_additional')->nullable(); + $table->string('phone_home')->nullable(); + + $table->string('work_region')->nullable()->index(); + $table->string('work_province')->nullable(); + $table->string('work_company')->nullable(); + $table->string('work_company_accountant_number')->nullable(); + $table->date('work_started_at')->nullable(); + $table->string('work_salary')->nullable(); + $table->string('work_position')->nullable(); + + $table->string('education'); + $table->string('marriage_status'); + + $table->text('passport_one'); + $table->text('passport_two'); + $table->text('passport_three'); + $table->text('passport_four'); + + $table->foreignId('filled_by')->constrained('users')->restrictOnDelete(); + $table->foreignId('user_id')->constrained('users')->restrictOnDelete(); + + $table->string('status')->index(); + $table->string('status_reason')->nullable(); + + $table->string('notes')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('loan_orders'); + } +};