Enhance CardOrder module: Add composer requirements and expand CardOrder model with properties, relationships, and soft deletes

This commit is contained in:
2025-10-23 01:37:06 +05:00
parent aff57eb574
commit 58725db7ea
3 changed files with 189 additions and 2 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Modules\CardOrder;
use App\Modules\Core\ModulePackage;
use App\Modules\Core\ModulePackageType;
use App\Modules\Makeable;
use App\Modules\ModuleContract;
@@ -51,7 +53,13 @@ class CardOrderModule implements ModuleContract
*/
public function getComposerRequirements(): array
{
return [];
return [
new ModulePackage(
type: ModulePackageType::MODULE,
name: 'Branch',
message: 'This module is used for branches.',
),
];
}
/**

View File

@@ -0,0 +1,72 @@
<?php
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
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('card_orders', function (Blueprint $table) {
$table->id();
$table->string('unique_id')->nullable()->unique();
$table->foreignId('card_state_id')->constrained('card_states')->restrictOnDelete();
$table->foreignId('card_type_id')->constrained('card_types')->restrictOnDelete();
$table->string('region', 2)->index();
$table->foreignId('branch_id')->constrained('branches')->restrictOnDelete();
$table->string('customer_name')->index();
$table->string('customer_surname')->index();
$table->string('customer_patronic_name')->nullable();
$table->date('born_at')->nullable();
$table->string('old_surname')->nullable();
$table->string('citizenship');
$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->string('job_location')->nullable();
$table->string('passport_address')->nullable();
$table->string('real_address')->nullable();
$table->string('phone')->nullable()->index();
$table->string('phone_additional')->nullable()->index();
$table->string('status')->nullable()->default(OrderStatusRepository::defaultStatus())->index();
$table->text('passport_one');
$table->text('passport_two');
$table->text('passport_three');
$table->text('passport_four');
$table->text('notes')->nullable();
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
$table->boolean('paid')->default(false);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('card_orders');
}
};

View File

@@ -2,6 +2,113 @@
namespace App\Modules\CardOrder\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 Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class CardOrder extends Model {}
/**
* @property int $id
* @property null|string $unique_id
* @property int $card_state_id
* @property int $card_type_id
* @property string $region
* @property int $branch_id
* @property string $customer_name
* @property string $customer_surname
* @property null|string $customer_patronic_name
* @property \Illuminate\Support\Carbon $born_at
* @property null|string $old_surname
* @property string $citizenship
* @property string $passport_serie
* @property string $passport_id
* @property \Illuminate\Support\Carbon $passport_given_at
* @property string $passport_given_by
* @property string $born_place
* @property null|string $job_location
* @property null|string $passport_address
* @property null|string $real_address
* @property null|string $phone
* @property null|string $phone_additional
* @property null|string $status
* @property string $passport_one
* @property string $passport_two
* @property string $passport_three
* @property string $passport_four
* @property null|string $notes
* @property int $user_id
* @property null|\Illuminate\Support\Carbon $created_at
* @property null|\Illuminate\Support\Carbon $updated_at
* @property null|\Illuminate\Support\Carbon $deleted_at
* @property bool $paid
*/
class CardOrder extends Model implements BelongsToBranch, HasStatus
{
use SoftDeletes;
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'born_at' => 'date',
'passport_given_at' => 'date',
'paid' => 'boolean',
];
/**
* User
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Card state
*
* @return BelongsTo<CardState, $this>
*/
public function cardState(): BelongsTo
{
return $this->belongsTo(CardState::class, 'card_state_id');
}
/**
* Card type
*
* @return BelongsTo<CardType, $this>
*/
public function cardType(): BelongsTo
{
return $this->belongsTo(CardType::class, 'card_type_id');
}
/**
* Branch
*
* @return BelongsTo<Branch, $this>
*/
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class, 'branch_id');
}
/**
* "boot" method for model
*/
protected static function boot()
{
parent::boot();
static::creating(LoanOrderRepository::creating());
static::created(LoanOrderRepository::created());
}
}