I am trying to run the query below but I keep getting null return.
$result = Order::with(['customers', 'team'])->where('customers_id','=', $custid)->select(sprintf('%s.*', (new Order)->table));
Then I changed it to
$result = Order::with(['customers', 'team'])->where(function($query) use ($cust) {$query->where('customers_id', $cust);})->select(sprintf('%s.*', (new Order)->table));
still returns null.
customers_id belongs to the orders table and references the customer's table. I am getting the $custid from the URL parameter.
If I replace $custid with an integer for example 3, it returns all orders for the customer with id 3. I have spent hours trying to resolve the issue. I have hosted on Heroku and localhost but nothing works.
$custid.href="{{ route('admin.orders.index', ['cid' => $row->id]) }}then in my orderscontroller@index$cust = $request->cid; Then this is the output of the querylog select count(*) as aggregate from (select '1' as row_count from orders where (customers_id is null) and orders.deleted_at is null) count_row_table [] select orders.* from orders where (customers_id is null) and orders.deleted_at is null []