Skip to content

Commit

Permalink
Laravel 11.x takes ->binary as varbinary column in the database
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapan-Tops committed May 27, 2024
1 parent 9a94918 commit bd3e51f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -116,7 +118,6 @@ You can refer the example, clicking on below Example button:

<a href="https://github.com/TapanDerasari/laravel-mysql-encrypt/blob/master/existing_data_encryption.md" target="new"><img src="https://img.shields.io/badge/Example-green"></a>


## License

The MIT License (MIT). Please
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit bd3e51f

Please sign in to comment.