PHP code example of xandanet / laravel-mysql-encrypt

1. Go to this page and download the library: Download xandanet/laravel-mysql-encrypt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xandanet / laravel-mysql-encrypt example snippets


'providers' => array(
    XandaNet\\MysqlEncrypt\\Providers\\LaravelServiceProvider::class
);

$app->register(XandaNet\MysqlEncrypt\Providers\LumenServiceProvider::class);



namespace App;

use XandaNet\MysqlEncrypt\Traits\Encryptable;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use Encryptable; // <-- 1. Include trait

    protected $encryptable = [ // <-- 2. Include columns to be encrypted
        'email',
        'first_name',
        'last_name',
        'telephone',
    ];
}

Schema::create('users', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('password');
    $table->rememberToken();
    $table->timestamps();
});

// 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)');
bash
php artisan vendor:publish --provider="XandaNet\MysqlEncrypt\Providers\LaravelServiceProvider"