I am making ecommerce app api using laravel and have 1 table for product data and another table for product images
This query works fine. I want nested query in which each product will have its list of images.I am making android app and need to show multiple product images in carousel slider and need to get nested JSON
$products = DB::table('products')->where ('stock_quantity', '<>' , 0 )->inRandomOrder()->get();
in products table I have unique 'id' and and same id is used in product_images table to map data.

hasManyandbelongsTothen fetch the productswith(images). In general outline