This commit is contained in:
2025-10-22 20:08:22 +05:00
commit 736e3bef18
2573 changed files with 120385 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Modules\LoanOrder\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class LoanOrderController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request): void
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): void
{
//
}
/**
* Display the specified resource.
*/
public function show(Request $request): void
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request): void
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Request $request): void
{
//
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('loan_types', function (Blueprint $table) {
$table->id();
$table->json('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_types');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('loan_order_required_docs', function (Blueprint $table) {
$table->id();
$table->text('name');
$table->text('value');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('loan_order_required_docs');
}
};

View File

@@ -0,0 +1,138 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('loan_orders', function (Blueprint $table) {
// Unique ID
$table->id();
$table->string('unique_id')->nullable()->unique();
// web, app
$table->string('source')->default('web')->index()->nullable();
// User
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
// Loan Type
$table->foreignId('loan_type')->constrained('loan_types')->restrictOnDelete();
// Region & Branch
$table->string('region', 2);
$table->foreignId('branch_id')->constrained('branches')->restrictOnDelete();
// Customer name,surname,patronic name
$table->string('customer_name')->index();
$table->string('customer_surname')->index();
$table->string('customer_patronic_name')->nullable();
// Passport address, real address
$table->string('passport_address');
$table->string('real_address');
// Passport data
$table->string('passport_serie')->index();
$table->string('passport_id')->index();
$table->date('passport_given_at');
$table->string('passport_given_by');
$table->string('born_place');
$table->date('born_at');
// Email, phone, phone additional, phone home
$table->string('email')->nullable();
$table->string('phone')->index();
$table->string('phone_additional')->nullable();
$table->string('phone_home')->nullable();
$table->string('work_region')->nullable()->index();
$table->foreignId('work_province_id')->nullable()->constrained('provinces')->restrictOnDelete();
$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')->index();
$table->string('marriage_status')->index();
$table->text('passport_one');
$table->text('passport_two');
$table->text('passport_three');
$table->text('passport_four');
$table->string('loan_amount')->nullable()->index();
$table->string('card_number')->nullable();
$table->string('card_name')->nullable();
$table->string('card_month')->nullable();
$table->string('card_year')->nullable();
// Guarantor one begin
$table->string('guarantor_name')->nullable();
$table->string('guarantor_surname')->nullable();
$table->string('guarantor_patronic_name')->nullable();
$table->string('guarantor_passport_serie')->nullable();
$table->string('guarantor_passport_id')->nullable();
$table->string('guarantor_card_number')->nullable();
$table->string('guarantor_card_name')->nullable();
$table->string('guarantor_card_month')->nullable();
$table->string('guarantor_card_year')->nullable();
$table->string('guarantor_note')->nullable();
// Guarantor one end
// Guarantor two begin
$table->string('guarantor_2_name')->nullable();
$table->string('guarantor_2_surname')->nullable();
$table->string('guarantor_2_patronic_name')->nullable();
$table->string('guarantor_2_passport_serie')->nullable();
$table->string('guarantor_2_passport_id')->nullable();
$table->string('guarantor_2_card_number')->nullable();
$table->string('guarantor_2_card_name')->nullable();
$table->string('guarantor_2_card_month')->nullable();
$table->string('guarantor_2_card_year')->nullable();
$table->string('guarantor_2_note')->nullable();
// Guarantor two end
// Loan card begin
$table->string('loan_card_number')->nullable();
$table->string('loan_card_name')->nullable();
$table->string('loan_card_month')->nullable();
$table->string('loan_card_year')->nullable();
$table->foreignId('loan_order_required_doc_id')->nullable()->constrained('loan_order_required_docs')->restrictOnDelete();
// Loan card end
$table->string('status')->nullable();
$table->string('satisfiable')->nullable();
$table->text('notes')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('loan_orders');
}
};

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Modules\LoanOrder;
use App\Modules\Core\ModulePackage;
use App\Modules\Core\ModulePackageType;
use App\Modules\Makeable;
use App\Modules\ModuleContract;
class LoanOrderModule implements ModuleContract
{
use Makeable;
/**
* Module is enabled
*/
protected bool $enabled = true;
/**
* Check if is module enabled
*/
public function isEnabled(): bool
{
return $this->enabled;
}
/**
* Disable module
*/
public function disable(): void
{
$this->enabled = false;
}
/**
* Enable module
*/
public function enable(): void
{
$this->enabled = true;
}
/**
* Check if module has a filament resource
*/
public function hasFilamentResource(): bool
{
return false;
}
/**
* Get module composer requirements
*/
public function getComposerRequirements(): array
{
return [
new ModulePackage(
type: ModulePackageType::PACKAGE,
name: 'spatie/laravel-translatable',
message: 'Laravel Translatable is required to use this module.',
),
];
}
/**
* Get module composer suggestions
*/
public function getComposerSuggestions(): array
{
return [];
}
}

View File

@@ -0,0 +1,173 @@
<?php
namespace App\Modules\LoanOrder\Models;
use App\Models\User;
use App\Modules\Branch\Interfaces\BelongsToBranch;
use App\Modules\Branch\Models\Branch;
use App\Modules\LoanOrder\Repositories\LoanOrderRepository;
use App\Modules\OrderStatus\Interfaces\HasStatus;
use App\Modules\Province\Models\Province;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
/**
* @property int $id
* @property string $unique_id
* @property string|null $source
* @property int|null $user_id
* @property int $loan_type
* @property string $region
* @property int $branch_id
* @property string $customer_name
* @property string $customer_surname
* @property string|null $customer_patronic_name
* @property string $passport_address
* @property string $real_address
* @property string $passport_serie
* @property string $passport_id
* @property Carbon $passport_given_at
* @property string $passport_given_by
* @property string $born_place
* @property Carbon $born_at
* @property string|null $email
* @property string $phone
* @property string|null $phone_additional
* @property string|null $phone_home
* @property string|null $work_region
* @property int|null $work_province_id
* @property string|null $work_company
* @property string|null $work_company_accountant_number
* @property Carbon|null $work_started_at
* @property string|null $work_salary
* @property string|null $work_position
* @property string $education
* @property string $marriage_status
* @property string $passport_one
* @property string $passport_two
* @property string $passport_three
* @property string $passport_four
* @property string|null $loan_amount
* @property string|null $card_number
* @property string|null $card_name
* @property string|null $card_month
* @property string|null $card_year
* @property string $guarantor_name
* @property string|null $guarantor_surname
* @property string|null $guarantor_patronic_name
* @property string|null $guarantor_passport_serie
* @property string|null $guarantor_passport_id
* @property string|null $guarantor_card_number
* @property string|null $guarantor_card_name
* @property string|null $guarantor_card_month
* @property string|null $guarantor_card_year
* @property string|null $guarantor_note
* @property string|null $guarantor_2_name
* @property string|null $guarantor_2_surname
* @property string|null $guarantor_2_patronic_name
* @property string|null $guarantor_2_passport_serie
* @property string|null $guarantor_2_passport_id
* @property string|null $guarantor_2_card_number
* @property string|null $guarantor_2_card_name
* @property string|null $guarantor_2_card_month
* @property string|null $guarantor_2_card_year
* @property string|null $guarantor_2_note
* @property string|null $loan_card_number
* @property string|null $loan_card_name
* @property string|null $loan_card_month
* @property string|null $loan_card_year
* @property int $loan_order_required_doc_id
* @property string|null $status
* @property string|null $satisfiable
* @property string|null $notes
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
*/
class LoanOrder extends Model implements BelongsToBranch, HasStatus
{
use SoftDeletes;
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'passport_given_at' => 'date',
'born_at' => 'date',
'work_started_at' => 'date',
];
/**
* Loan type
*
* @return BelongsTo<LoanType, $this>
*/
public function loanType(): BelongsTo
{
return $this->belongsTo(LoanType::class, 'loan_type');
}
/**
* Branch
*
* @return BelongsTo<Branch, $this>
*/
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class);
}
/**
* Work province
*
* @return BelongsTo<Province, $this>
*/
public function workProvince(): BelongsTo
{
return $this->belongsTo(Province::class, 'work_province_id');
}
/**
* User (who created order)
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
/**
* Required docs
*
* @return BelongsTo<LoanOrderRequiredDocs, $this>
*/
public function requiredDocs(): BelongsTo
{
return $this->belongsTo(LoanOrderRequiredDocs::class, 'loan_order_required_doc_id');
}
/**
* "boot" method for model
*/
protected static function boot()
{
parent::boot();
static::creating(LoanOrderRepository::creating());
static::created(LoanOrderRepository::created());
// static::updated(function (LoanOrder $model) {
// if ($model->notes && $model->wasChanged('notes')) {
// Alert::create([
// 'user_id' => $model->user_id,
// 'name' => 'Duýdyryş',
// 'value' => $model->notes,
// ]);
// }
// });
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Modules\LoanOrder\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Translatable\HasTranslations;
/**
* @property int $id
* @property string $name
* @property string $value
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
*/
class LoanOrderRequiredDocs extends Model
{
use HasTranslations;
/**
* Table
*/
protected $table = 'loan_order_required_docs';
/**
* Translatable fields
*
* @var array<int, string>
*/
public $translatable = [
'name',
'value',
];
/**
* Loan orders
*
* @return HasMany<LoanOrder, $this>
*/
public function loanOrders(): HasMany
{
return $this->hasMany(LoanOrder::class, 'loan_order_required_doc_id');
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Modules\LoanOrder\Models;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
/**
* @property int $id
* @property array<string, string> $name
* @property string|null $tax
* @property string|null $maturity
* @property string|null $notes
* @property bool $active
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
*/
class LoanType extends Model
{
use HasTranslations;
/**
* Translatable fields
*
* @var array<string>
*/
public $translatable = ['name', 'notes'];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'active' => 'boolean',
];
}

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Modules\LoanOrder\Repositories;
use App\Modules\Branch\Interfaces\BelongsToBranch;
use App\Modules\Branch\Models\Branch;
use App\Modules\OrderStatus\Interfaces\HasStatus;
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
use Closure;
class LoanOrderRepository
{
/**
* Satisfiable values
*
* @return array<string|null, string>
*/
public static function satisfiableValues(): array
{
return [
null => '-',
'satisfiable' => __('Satisfiable'),
'insufficient' => __('Insufficient'),
'unknown' => __('Unknown'),
];
}
/**
* When model is being created
*/
public static function creating(): Closure
{
return function (HasStatus $model) {
$model->status = $model->status ?: OrderStatusRepository::defaultStatus();
};
}
/**
* When model is created
*/
public static function created(): Closure
{
return function ($model) {
$model->update(['unique_id' => static::generateUniqueId($model)]);
};
}
/**
* Fill unique id
*/
public static function generateUniqueId(BelongsToBranch $model): string
{
return sprintf(
'TB%s-%s',
Branch::find($model->branch_id)->unique_code ?? uniqid(),
$model->id,
);
}
}

View File

@@ -0,0 +1,10 @@
<?php
return [
'loan' => 'Karz',
'loans' => 'Karzlar',
'loan_order' => 'Karz sargyt',
'loan_orders' => 'Karz sargytlary',
'loan_order_required_docs' => 'Karz gerekli resminamalar',
'loan_order_required_docs_plural' => 'Karz gerekli resminamalar',
];

View File

@@ -0,0 +1,6 @@
<?php
return [
'loan_type' => 'Karz görnüşi',
'loan_types' => 'Karz görnüşleri',
];