Skip to content
Advertisement

Laravel, how to display Values in DB with just given IDs?

im trying to get 5 data from DB with their ID ?

HTML

JavaScript

Route

JavaScript

Controller – im Trying to get Just 1 ID and its not Working

JavaScript

I want to show 5 Offers from Offers Table, with given 5 ID in HTML Form ? How can i do this in Laravel ?

Advertisement

Answer

You never execute your query… where() is a Query Builder instance, until you call ->first() or ->get(). If you want 1 record, then use first(), if you want multiple, then use get().

Or, in your case, you can use find():

JavaScript

If you want to get all 5, then you’d call:

JavaScript

Or, if no other input is being passed from your form:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement