Skip to content
Advertisement

Tag: eloquent

How to use the passed data in to a sql query?

How do I pass the $id into my $record SQL query and what is the eloquent query as well? I want to do this because the user_id is the foreign key from borrows. I want to pull data from payment_records that have the same id with the selected id. This is the show method where I passed the id and

Eloquent hasMany doesn’t load collection

I’m relatively new to eloquent, and have problems loading data from a hasMany relation in an app that uses eloquent as the database layer. My (simplified) code is as follows: The SQL Schema is like below I then do the following query: This results in a json like the following Raw SQL query shows me that I do have data

Advertisement