PHP code example of striderwhite / encryptable

1. Go to this page and download the library: Download striderwhite/encryptable 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/ */

    

striderwhite / encryptable example snippets


use StriderWhite\Encryptable;

class YourModel extends Model
{
    use Encryptable;

    protected $encryptable = ['field1', 'field2'];
}

use App\Models\YourModel;

// Persisting data
$model = new YourModel();
$model->field1 = 'Sensitive Data';
$model->field2 = 'Another Secret';
$model->save();

// Retrieving data
$retrievedModel = YourModel::find($model->id);
echo $retrievedModel->field1; // Outputs: Sensitive Data
echo $retrievedModel->field2; // Outputs: Another Secret

YourModel::whereEncrypted('field1', 'value')->get();

YourModel::whereEncryptedLike('field1', 'value')->get();