PHP code example of hamoi1 / eloquent-encryptable

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

    

hamoi1 / eloquent-encryptable example snippets


use Hamoi1\EloquentEncryptAble\Services\EloquentEncryptAbleService;

$cipher = new EloquentEncryptAbleService();
$encrypted = $cipher->encrypt('Hello, World!');
$decrypted = $cipher->decrypt($encrypted);

$encrypted ='"Ejrno, Wtenl!";
$decrypted = 'Hello, World!';

use Illuminate\Database\Eloquent\Model;
use Hamoi1\EloquentEncryptAble\Traits\EncryptAble;

class User extends Model
{
    use EncryptAble;

    public $encryptAble = ['name', 'email'];
}

$user = new User();
$user->name = 'John Doe';
$user->email = '[email protected]';
$user->save();

$user = User::find(1);
$user->name; // John Doe
$user->email; // [email protected]

'models' => [
    User::class,
    Category::class
],

use Hamoi1\EloquentEncryptAble\Rules\EncryptAbleUniqueRule;

$request->validate([
    'email' => ['

use Hamoi1\EloquentEncryptAble\Rules\EncryptAbleUniqueRule;

$request->validate([
    'email' => ['

use Hamoi1\EloquentEncryptAble\Rules\EncryptAbleExistsRule;

$request->validate([
    'email' => ['

use Hamoi1\EloquentEncryptAble\Rules\EncryptAbleExistsRule;

$request->validate([
    'email' => ['
bash
php artisan vendor:publish  --provider="Hamoi1\\EloquentEncryptAble\\EloquentEncryptAbleServiceProvider" --tag="config"
bash
php artisan eloquent-encryptable:re-encrypt