mardi 3 septembre 2019

apply filtering on query with left join

guys i'm writing a filter for admin to view transaction histories about orders.

search form have 3 input . i added 3 where() query for filters ... but its not working.
how can i add where query to my query if searching value what is comming via form is present and isnt null?

public function search(Request $request){


        //dd($request->all());
        $order_id = $request->get('order_id');
        $transaction_id = $request->get('transaction_id');
        $tracking_code = $request->get('tracking_code');

        $orderHistories = DB::table('gateway_transactions')
            ->leftJoin("order_transactions", "gateway_transactions.id", "=", "order_transactions.transaction_id")
            ->leftJoin("orders", "order_transactions.order_id", "=", "orders.id")
            ->leftJoin("gateway_transactions_logs", "gateway_transactions.id", "=", "gateway_transactions_logs.transaction_id")
            ->where('orders.id', $order_id)->where('gateway_transactions.id', $transaction_id)->where('tracking_code', $tracking_code)->paginate(10);



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NQ3OV5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire