Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with join() #29

Open
n-o-o-b-z opened this issue Jan 26, 2023 · 5 comments
Open

Not working with join() #29

n-o-o-b-z opened this issue Jan 26, 2023 · 5 comments

Comments

@n-o-o-b-z
Copy link

It is not working using laravel join()

@Onkar-php-digi
Copy link

Same have you find any solution ?

@n-o-o-b-z
Copy link
Author

not yet, I'm still waiting, how about you?

@Onkar-php-digi
Copy link

Onkar-php-digi commented Feb 8, 2023

I have sorted it with Laravel relations, and it works fine for me.

$data_message = [];
$results = Message::with(['fromUser' => function ($query) {
$query->select('id', 'name', 'email', 'image');
}])
->where('to_user_id', $user_id)
->where('is_read',0)
// ->groupBy('from_user_id')
->orderBy('id','DESC')
->get();
$results = $results->unique('from_user_id');

@mastahed
Copy link

$salt = substr(hash('sha256', env('APP_KEY')), 0, 16);

Just create a sub select query:

Table::selectRaw('(select AES_DECRYPT(FROM_bASE64(email_address), "'.$salt.'") from your_table where column.id = other_table.other_id) as decrypted_email')
->get()

@mastahed
Copy link

You can also use DB::select and add raw mysql statement

`$salt = substr(hash('sha256', env('APP_KEY')), 0, 16);

$results = DB::select("
SELECT
temp.first_name,
temp.last_name,
CASE
WHEN p.id IS NOT NULL THEN 'Matched'
ELSE 'No Match Found'
END as match_status
FROM temp_data AS temp
LEFT JOIN your_table AS p
ON temp.first_name = (AES_DECRYPT(FROM_bASE64(p.first_name), '".$salt."'))
AND temp.last_name = (AES_DECRYPT(FROM_bASE64(p.last_name), '".$salt."'))
AND (temp.email_address = (AES_DECRYPT(FROM_bASE64(p.email_address), '".$salt."')) AND p.email_address IS NOT NULL)
");`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants