I have categories table and products table. in products table have category_id column type of integer[]. ex: {1,2,3} . And I need products list with category relation which categories.id exist products.category_id I tried in model Product: no get category is null. Answer I can’t relation but with attribute i can get categories firstly cast category_id to array and and it
Tag: relation
Image Preview from DB
I’m Trying to Preview images from database as im saving album in table albums and album images in table images and connecting with relation but i can’t preview the images from table image so i’m adding relations between the 2 tables and trying to preview the images but its not working with me something went wrong but i cannot figure
Eloquent – Update eloquent relations with foreach loop
I have a controller function to send multiple devices for repair (essentially an update request against multiple existing devices_repairs records). When I try to retrieve the devices from the devices table alongside the repair details (Devices table, devices_repairs table), the records are retrieved but when I try to update the values the update request doesn’t save the new data. This
Laravel – Eloquent: get posts from user with users post table
I searched a lot but could not find any answer about it, so I hope you could help me! I have three tables: posts, users and post_users. Post_users contains two columns: user_id and post_id. I need to get all posts by an user with Eloquent. Any ideas? Answer Model User: Model Post: Try: