From bd3e51fe6595db2de39b777983f36c8589ab63e3 Mon Sep 17 00:00:00 2001 From: Tapan Date: Mon, 27 May 2024 16:41:58 +0530 Subject: [PATCH] Laravel 11.x takes ->binary as varbinary column in the database --- README.md | 5 +++-- tests/TestCase.php | 1 - tests/Unit/DatabaseTest.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 788dbc1..65d246c 100644 --- a/README.md +++ b/README.md @@ -91,17 +91,19 @@ Global scope `DecryptSelectScope` automatically booted in models using `Encrypta Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('password'); + $table->binary('first_name',300); // VARBINARY(300) for laravel 11.x and above versions $table->rememberToken(); $table->timestamps(); }); -// Once the table has been created, use ALTER TABLE to create VARBINARY +// for laravel 10.x and below version, Once the table has been created, use ALTER TABLE to create VARBINARY // or BLOB types to store encrypted data. DB::statement('ALTER TABLE `users` ADD `first_name` VARBINARY(300)'); DB::statement('ALTER TABLE `users` ADD `last_name` VARBINARY(300)'); DB::statement('ALTER TABLE `users` ADD `email` VARBINARY(300)'); DB::statement('ALTER TABLE `users` ADD `telephone` VARBINARY(50)'); ``` + ## Implementing encryption for existing data For this you can create one command like @@ -116,7 +118,6 @@ You can refer the example, clicking on below Example button: - ## License The MIT License (MIT). Please diff --git a/tests/TestCase.php b/tests/TestCase.php index f632164..72aabe5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,7 +4,6 @@ use Orchestra\Testbench\TestCase as Orchestra; use TapanDerasari\MysqlEncrypt\Providers\LaravelServiceProvider; -use TapanDerasari\MysqlEncrypt\Tests\Models\Demo; class TestCase extends Orchestra { diff --git a/tests/Unit/DatabaseTest.php b/tests/Unit/DatabaseTest.php index 4a8ead1..8134a80 100644 --- a/tests/Unit/DatabaseTest.php +++ b/tests/Unit/DatabaseTest.php @@ -11,6 +11,7 @@ $schema->create('testing', function (Blueprint $table) { $table->increments('id'); $table->string('value'); + //$table->binary('value',1024); //For Laravel 11.x and above vesions $table->timestamps(); });