'Laravel empty pagination data

My query from Laravel Builder toSql() function.

select `dispatcher_leads`.*, 
(select
CASE WHEN lead_positions.order_type = 'shift' THEN DATE_ADD(lead_positions.date_from, INTERVAL lead_positions.order_duration DAY) WHEN lead_positions.order_type ='hour' THEN DATE_ADD(lead_positions.date_from, INTERVAL lead_positions.order_duration HOUR) END from `lead_positions` where `dispatcher_leads`.`id` = `lead_positions`.`lead_id`) as `end_date` 

from `dispatcher_leads` where `domain_id` = ? and `status` = ? and `company_branch_id` = ? and `customer_type` = ? and `status` = ? and `dispatcher_leads`.`deleted_at` is null order by `dispatcher_leads`.`start_date` asc

In DB records exists.

enter image description here

if i remove this block

 $leads->withCount(['positions as end_date' => function ($query) {
        $query->select(DB::raw("
                    CASE  
                    WHEN lead_positions.order_type = 'shift'
                    THEN DATE_ADD(lead_positions.date_from, INTERVAL lead_positions.order_duration DAY)
                     WHEN lead_positions.order_type ='hour'
                    THEN DATE_ADD(lead_positions.date_from, INTERVAL lead_positions.order_duration HOUR)
                    END
                    "));
    }]);

Everything is ok. Please help to reolve it.



Solution 1:[1]

To see data, you must go to the first page

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Milad Azizi