Skip to content

Commit bd3e51f

Browse files
committed
Laravel 11.x takes ->binary as varbinary column in the database
1 parent 9a94918 commit bd3e51f

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,19 @@ Global scope `DecryptSelectScope` automatically booted in models using `Encrypta
9191
Schema::create('users', function (Blueprint $table) {
9292
$table->bigIncrements('id');
9393
$table->string('password');
94+
$table->binary('first_name',300); // VARBINARY(300) for laravel 11.x and above versions
9495
$table->rememberToken();
9596
$table->timestamps();
9697
});
9798

98-
// Once the table has been created, use ALTER TABLE to create VARBINARY
99+
// for laravel 10.x and below version, Once the table has been created, use ALTER TABLE to create VARBINARY
99100
// or BLOB types to store encrypted data.
100101
DB::statement('ALTER TABLE `users` ADD `first_name` VARBINARY(300)');
101102
DB::statement('ALTER TABLE `users` ADD `last_name` VARBINARY(300)');
102103
DB::statement('ALTER TABLE `users` ADD `email` VARBINARY(300)');
103104
DB::statement('ALTER TABLE `users` ADD `telephone` VARBINARY(50)');
104105
```
106+
105107
## Implementing encryption for existing data
106108

107109
For this you can create one command like
@@ -116,7 +118,6 @@ You can refer the example, clicking on below Example button:
116118

117119
<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>
118120

119-
120121
## License
121122

122123
The MIT License (MIT). Please

tests/TestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Orchestra\Testbench\TestCase as Orchestra;
66
use TapanDerasari\MysqlEncrypt\Providers\LaravelServiceProvider;
7-
use TapanDerasari\MysqlEncrypt\Tests\Models\Demo;
87

98
class TestCase extends Orchestra
109
{

tests/Unit/DatabaseTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
$schema->create('testing', function (Blueprint $table) {
1212
$table->increments('id');
1313
$table->string('value');
14+
//$table->binary('value',1024); //For Laravel 11.x and above vesions
1415
$table->timestamps();
1516
});
1617

0 commit comments

Comments
 (0)