PHP code example of adityadarma / laravel-database-cryptable

1. Go to this page and download the library: Download adityadarma/laravel-database-cryptable 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/ */

    

adityadarma / laravel-database-cryptable example snippets


    
    use AdityaDarma\LaravelDatabaseCryptable\Traits\CryptableAttribute;

    class User extends Eloquent {
        use CryptableAttribute;
       
        /**
         * The attributes that should be encrypted on save.
         *
         * @var array
         */
        protected $encryptable = [
            'first_name', 'last_name'
        ];
    }

    namespace App\Http\Controllers;

    use App\Models\User;
    class UsersController extends Controller {
        public function index(Request $request)
        {
            $user = User::whereEncrypted('first_name','john')
                        ->orWhereEncrypted('last_name','!=','Doe')
                        ->orderByEncrypted('last_name', 'asc')
                        ->firstOrFail();
            
            return $user;
        }
    }

      $validator = validator(['email'=>'[email protected]'], ['email'=>'unique_encrypted:users,email']);