I am trying to go by default if the relationship does not yet have order. But if so, I am not using the default value.
$q = $this->items(); if (empty($q->orders)) { $q = $q->order(); }
Note that order() is only the default method in a BaseModel class. For some reason, when I try to call the orders property in the query builder, it says Undefined property , although this is a public property in the Builder class.
I donβt know why, or how I can check it.
EDIT:
I set the complete example in the route:
class Test extends \Illuminate\Database\Eloquent\Model {} $router->get('/test', function () { $test = new Test; $q = $test->select('id')->orderBy('id', 'desc'); $bindings = $q->getRawBindings(); var_dump($bindings); return 'test'; });
Is the dump just splashing out the query builder object, not the bindings?
source share