how i can use like query in aes_encryption in laravel

How i can use like search query in Aes_encryption data in laravel .my data in tables is in AES Encryption form . i try this code but its not work well. please help me. Thanks in Advance.

     public static function search($type, $value, $limit = 12){
$key = self::encryption_key;
if($type == "name"){
$valuess = DB::raw("AES_ENCRYPT('$value',$key)");
$values = Crypt::encrypt($valuess);
}elseif($type == "phone"){
$valuess = DB::raw("AES_ENCRYPT('$value',$key)");
$values = Crypt::encrypt($valuess);
}elseif($type == "email"){
$valuess = DB::raw("AES_ENCRYPT('$value',$key)");
$values = Crypt::encrypt($valuess);
}elseif($type == "tag"){
$values = $value;
}else{
$valuess = DB::raw("AES_ENCRYPT('$value',$key)");
$values = Crypt::encrypt($valuess);
}
$types = Customer::getTranslatedType($type);
$user_id = Auth::user()->id;
$data = DB::table("user_customers")->select(DB::raw("customers.status, customers.id, user_customers.tag as tag, SUM(CASE WHEN uploads.views=0 AND folders.isPrivate = 0 THEN 1 ELSE 0 END) as unread,
SUM(CASE WHEN uploads.status=1 AND folders.isPrivate = 0 THEN 1 ELSE 0 END) as unprocessed, companies.id as company_id ," .(new static)->columnsToAESDecryptHelper(array("companies.name" => "name", "companies.email" => "email", "companies.phone" => "phone", "companies.address" => "address"))))
->join("customers", "customers.id", "user_customers.customer_id")
->join("users", "user_customers.user_id", "users.id")
->leftjoin("folders", "users.id", "folders.user_id")
->leftjoin("uploads", "folders.id" , DB::raw("uploads.folder_id AND customers.id = uploads.customer_id"))
->leftjoin("companies", "user_customers.company_id", "companies.id")
->where("user_customers.user_id", $user_id)
->where($types, 'LIKE',"%{$values}%")
// ->groupBy(DB::raw("customers.id , customers.user_id"))
->groupBy(DB::raw("companies.id"))
->orderBy('customers.id','desc')
->paginate($limit);
// dd($data);
return $data;

from Newest questions tagged laravel-5 – Stack Overflow https://ift.tt/351myrj
via IFTTT

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

C√≥mo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.