1

I have 3 payout tables. All are grouping by 'mem_id'. Now I want to filter date wise search by any one of the table having the date period.

This is my Code but its not working:

$payout = Payout::join('tbl_payout2', 'tbl_payout.mem_id', '=', 
                        'tbl_payout2.mem_id')
                ->join('tbl_payout3','tbl_payout.mem_id', '=','tbl_payout3.mem_id')
                ->Where(function ($query) use ($first, $last)  {
                    $query->whereBetween('tbl_payout.dop',[
                        date('Y-m-d', strtotime($first)),
                        date('Y-m-d', strtotime($last))
                    ])
                    ->OrWhereBetween('tbl_payout2.dop',[
                        date('Y-m-d', strtotime($first)),
                        date('Y-m-d', strtotime($last))
                    ])
                    ->OrWhereBetween('tbl_payout3.dop',[
                        date('Y-m-d', strtotime($first)),
                        date('Y-m-d', strtotime($last))
                    ]);

                })->Select(DB::Raw('count(*) as count2, 
                    (tbl_payout.tds+tbl_payout2.tds+tbl_payout3.tds) 
                        AS tds_total,
                    (tbl_payout.admin+tbl_payout2.admin+tbl_payout3.admin) 
                        AS admin_total,
                    (tbl_payout.paid+tbl_payout2.paid+tbl_payout3.paid) 
                        AS paid_total,
                    (tbl_payout.svc+tbl_payout2.rc+tbl_payout3.invest) 
                        AS earning, tbl_payout.*')

                )->GroupBy('tbl_payout.mem_id')
                ->paginate(25);

For Example if Payout table contains date between 01.01.2010 to 31.01.2010 and Payout-2 table contains date between 15.01.2010 to 15.02.2010 and Payout-3 table contains date between 01.02.2010 to 28.02.2010.

If I want to filter 15.01.2010 to 28.02.2010 it should be give all in the in between rows in all tables.

How to achieve this?

Jasmel Singh
  • 111
  • 1
  • 6
Karthik SWOT
  • 1,129
  • 1
  • 11
  • 15

0 Answers0