I'm using Laravel Query Builder to query MySQL database but it returns integer values as string values.
I have the following query.
$query = DB::table('store_products')->select('products.id', 'products.name', 'products.unit_type', 'products.price', 'products.image_path', 'products.is_popular', 'store_products.price AS store_price')
->join('products', 'products.id', '=', 'store_products.product_id')
->join('product_categories', 'product_categories.product_id', '=', 'store_products.product_id')
->where('store_products.store_id', $store_id)
->where('store_products.product_id', $product_id);
Here the query gets Product which is existing in Store_Products
for given store_id
.
The problem is, it returns id
(which is the Primary Key for Product) as string
when I use Query Builder. Looks like there is something wrong with casts.
How can I solve this problem?
Thank you very much in advance.