Skip to content

Pagination fails on adding column alias and having condition on alias #16825

@funyug

Description

@funyug
  • Laravel Version: 5.1.45
  • PHP Version: 5.6
  • Database Driver & Version:Mysql

Description:

Pagination fails on adding column alias and having condition on alias due to the count query that is run without the select query.

Steps To Reproduce:

$data = PropertyRent::select(DB::raw('min(rent) as min_rent,property_id'))->groupBy('property_id')->having('min_rent','>=',1000)->paginate();

Error:
Unknown column 'min_rent' in 'having clause' (SQL: select count(*) as aggregate from property_rents group by condominium_id having min_rent >= 1000)'

Note: the get() query works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions