So this is the query I have constructed so far
$data['requested_units'] = RequestedUnit::with([
'user',
'agent_warrants' => function ($q) {
$q->where('type', RequestedUnit::AgentSecurityWarrant);
}
])
->where('status', RequestedGrant::REQUESTED)
->get();
the problem is that it assumes the 'type' column is in the table 'agent_warrants' but actually it is in the parent table i-e RequestedUnit , how to specify this?
agent_warrantswhen the type ofRequestedUnitisRequestedUnit::AgentSecurityWarrant?RequestedUnit::where('type',RequestedUnit::AgentSecurityWarrant) }])and then->with(['agent_warrants'])