I am attempting to use the following
$orders = \App\Order::with([
'Customer' => function ($query) use ($filterFirst, $filterLast, $filterstate)
{
if($filterFirst)
{
$query->where('customers.first', 'LIKE', "{$filterFirst}%");
}
if($filterLast)
{
$query->where('customers.last', 'LIKE', "{$filterLast}%");
}
if ($filterstate)
{
$query->where('customers.state', '=', $filterstate);
}
}
However, when I run ->get
on $orders
I get the entire table of orders, and I just want to get the orders that match the Customer Filters...
Any ideas on how I can accomplish this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire