I have Two Tables
'Orders' with Columns
['subtotal', 'taxes', 'delivery_fee', 'total', 'discount', 'status', 'delivery_status','payment_status', 'special_instructions', 'address_id', 'store_id', 'user_id', 'delivery_profile_id','payment_method_id', 'type', 'scheduled_on'];
And
'Stores' with Columns
['name', 'tagline', 'image_url', 'delivery_time', 'minimum_order','delivery_fee', 'details', 'delivery_limit', 'area', 'address', 'longitude', 'latitude', 'preorder','serves_non_veg', 'cost_for_two', 'status', 'owner_id', 'apibot', 'admin_id','admin_mobile', 'opens_at', 'closes_at'];
Iam running a Laravel 5.5 Framework and Having Tough time to build a Query. Below is my Complete Code fr returning the Order List according to requested Status from my Mobile API
$orders = Order::where('store_id', Auth::user()->store->id);
if($request->status) {
$orders = $orders->where('status', $request->status);
}
// filter for active orders
if($request->active_orders) {
$orders = $orders->whereIn('status', ['new', 'accepted', 'preparing', 'dispatched']);
}
// for delivery tab in store app
if($request->deliveries) {
$orders = $orders->whereIn('status', ['accepted', 'preparing', 'dispatched'])
->where('delivery_profile_id', '<>', null)
->whereIn('delivery_status', ['allotted', 'started', 'complete']);
}
In the Below Code I need to put a Join and Where Clause combination to Join Store with Orders
$orders = Order::where('store_id', Auth::user()->store->id);
For Example: General SQL Query as Follows
Select * From Orders, Stores Where Stores.id=Orders.store_id and Stores.admin_id = 17
I tried with Possible solutions but not successful. Thank you in Advance.