1. Go to this page and download the library: Download hivelink/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/ */
use Hivelink\DBEncryption\Traits\EncryptedAttribute;
class User extends Eloquent {
use EncryptedAttribute;
/**
* The attributes that should be encrypted on save.
*
* @var array
*/
protected $encryptable = [
'first_name', 'last_name'
];
}
Route::get('/', function () {
$loadLib=new Encrypter();
$text="Hi my Dear?";
$userMail/$userPhone="[email protected]";
$userRecord/OtherData=2342342;
$encData=$loadLib->encryptUser($text,$userMail,$userRecord);
$decData=$loadLib->decryptUser($encData,$userMail,$userRecord);
return $decData
});
namespace App\Http\Controllers;
use App\User;
class UsersController extends Controller {
public function index(Request $request)
{
$user = User::whereEncrypted('first_name','john')
->orWhereEncrypted('last_name','!=','Doe')->firstOrFail();
return $user;
}
}