1 week ago

Query builder returning null

Posted 1 week ago by gixroq

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 customers 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 on trying to resolve the issue. I have hosted on heroku and localhost but nothing works.

I am currently using Windwos 8.

Please sign in or create an account to participate in this conversation.