Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

Honestly I have no idea at all what you are trying to achieve. First of all you are enclosing md5("id") in single quote so it is just considered as string so it will try to find $md5_valued_string_get_from_url in the md5("id") column. I don't really get what you are trying to achieve here so I can't give you a real answer unless you give me some more informations :)

Last updated 1 year ago.
0

I don't understand either... Why would you MD5 the column name?

I suppose that what you want to do, is check if the MD5 hash in URL matches some ID (which is non hashed) in your database. This can not (i suppose) be done easily without a loop (because you can not unhash MD5) of all your records.

I suggest you to save another column named "hash" (MD5 or another) and query records by this from URL (not by hashed ID)

Last updated 1 year ago.
0

Hey @zaalbarxx and @TorchSK I am applogies for my question. Now I will try to give you brief what I want,

consider the below query as an example

SELECT * FROM table_name WHERE md5( category_id) = 'c4ca4238a0b923820dcc509a6f75849b'

I want to create this query with Eloquent model.

I hope this time I am pretty much clear with my question :)

Last updated 1 year ago.
0

Still don't get the idea, but if you want to build query like this one use:

$record = TestRecord::where(DB::raw('md5("id")') , $md5_valued_string_get_from_url);
Last updated 1 year ago.
0

@zaalbarxx: Thanks for your help. It worked.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.