mardi 1 juin 2021

Get date with relation using two columns in Laravel

I have a table named as users:

id |  name |  email  

and attachment table

id |  file_name   |  user_id  |  type 
1    filename1.jpg      56         7
2    filename2.jpg      56         7
3    filename3.jpg      57         7
4    filename4.jpg      56         6

i'm fetching data from users table like:

 $data = Users::find($id);

but i want to get attachment table data also with users table. But i want to match user_id and type also, where user_id matches and type = 7 only those rows should return.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3vIcJex
via IFTTT

Aucun commentaire:

Enregistrer un commentaire