2 years ago

Query from two tables with 'Where' conditions

Posted 2 years ago by yansusanto
@foreach ($orders as $order)
<select class="custom-select" name="agent_id">
@foreach($agents as $agent)
    // Not sure if this is the right way of doing it but I prefer to set the condition in my controller...
    @if($agent->location == $order-location)
        <option value="{{ $agent->id }}">{{ $agent->name }}</option>
$orders = Order::with('user', 'invoice')

$agents = User::whereStatus(3)
    ->orWhere('location', ????) // how do I set the conditon is here where ($agent->location == $order-location)
    ->get(['id', 'name', 'location']);
return view('dashboard', compact('orders', 'agents'));

Appreciate if anyone could point me in the right direction. Many thanks ;)

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