Skip to content

Commit 519d1df

Browse files
committed
Fixed updateModelCertificate and update verify block
1 parent 29ee981 commit 519d1df

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

database/migrations/2025_11_07_000002_create_model_has_certificates_table.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public function up(): void
1111
Schema::create('model_has_certificates', function (Blueprint $table) {
1212
$table->id();
1313
$table->unsignedBigInteger('user_id')->index();
14-
$table->string('certificate_path'); // example: storage/app/certificates/user1.pem
14+
$table->string('private_key_path'); // example: storage/app/certificates/private.pem
15+
$table->string('public_key_path'); // example: storage/app/certificates/public.pem
1516
$table->integer('status')->max(2)->default(1);
1617
$table->timestamps();
1718

src/BlockchainManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function getPublicKeyPath(BlockchainLedger $block): string
8989
}
9090

9191
if ($block->with_user_certificate == 1) {
92-
$publicKeyPath = $block->userCertificate->certificate_path;
92+
$publicKeyPath = $block->userCertificate->public_key_path;
9393
} elseif ($block->with_user_certificate == 0) {
9494
$publicKeyPath = $block->defaultCertificate->public_key_path;
9595
} else {
@@ -252,8 +252,8 @@ public function verifyBlock(BlockchainLedger $block): bool
252252

253253
if ($block->with_user_certificate == 1) {
254254
$certificate = ModelHasCertificate::where('id', $block->certificate_id)->first();
255-
if ($certificate && file_exists(storage_path($certificate->certificate_path)) && $block->with_user_certificate == 1) {
256-
$publicKeyPath = storage_path($certificate->certificate_path);
255+
if ($certificate && file_exists(storage_path($certificate->public_key_path)) && $block->with_user_certificate == 1) {
256+
$publicKeyPath = storage_path($certificate->public_key_path);
257257
}
258258
}
259259

src/Models/ModelHasCertificate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class ModelHasCertificate extends Model
1010

1111
protected $fillable = [
1212
'user_id',
13-
'certificate_path',
13+
'private_key_path',
14+
'public_key_path',
1415
'status',
1516
];
1617
}

0 commit comments

Comments
 (0)