GithubHelp home page GithubHelp logo

justbetter / laravel-pagination-with-havings Goto Github PK

View Code? Open in Web Editor NEW
66.0 5.0 10.0 10 KB

Makes it possible to use pagination with havings in queries with Laravel.

License: MIT License

PHP 100.00%
laravel pagination

laravel-pagination-with-havings's Introduction

Laravel Pagination with Havings

This package is not needed anymore from Laravel 7.10.0 and up. This is fixed by Taylor Otwell with this PR: laravel/framework#32624


This Laravel package makes it possible to use Laravel's pagination with queries which are using havings. Without it you probably get "Column not found" MySQL errors. For more information see:

Installation

composer require justbetter/laravel-pagination-with-havings

Usage

Just use the trait on the model.

Example

use JustBetter\PaginationWithHavings\PaginationWithHavings;

class MyModel extends Eloquent
{
    use PaginationWithHavings;

    ...
}

Ideas, bugs or suggestions?

Please create a issue or a pull request.

License

MIT

About us

We’re a innovative development agency from The Netherlands building awesome websites, webshops and web applications with Laravel and Magento. Check out our website justbetter.nl and our open source projects.


JustBetter logo

laravel-pagination-with-havings's People

Contributors

billmn avatar denitsa-md avatar royduin avatar veneliniliev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

laravel-pagination-with-havings's Issues

This package doesn't seem to support Laravel 5.8

When I install an error like this appears:

Problem 1 - Installation request for justbetter/laravel-pagination-with-havings ^1.0 -> satisfiable by justbetter/laravel-pagination-with-havings[1.0]. - Conclusion: remove laravel/framework v5.8.2 - Conclusion: don't install laravel/framework v5.8.2 - justbetter/laravel-pagination-with-havings 1.0 requires laravel/framework ~5.5.0|~5.6.0|~5.7.0 -> satisfiable by laravel/framework[5.5.x-dev, 5.6.x-dev, 5.7.x-dev]. - Can only install one of: laravel/framework[5.5.x-dev, v5.8.2]. - Can only install one of: laravel/framework[5.6.x-dev, v5.8.2]. - Can only install one of: laravel/framework[5.7.x-dev, v5.8.2]. - Installation request for laravel/framework (locked at v5.8.2, required as 5.8.*) -> satisfiable by laravel/framework[v5.8.2]

Hello Dear, i still have the issue

I have install the package, and loaded in model

latitude;){ $longitude =$request->longitude; $doctors = DB::table("directories"); $doctors = $doctors->select("*", DB::raw("3959* acos(cos(radians(" . $latitude . ")) * cos(radians(latitude)) * cos(radians(longitude) - radians(" . $longitude . ")) + sin(radians(" .$latitude. ")) * sin(radians(latitude))) AS distance")); $doctors = $doctors->having('distance', '<', 100); $doctors = $doctors->orderBy('distance', 'asc'); $doctors =$doctors->paginate(100); } but i still have the same error, Laravle 5.7 SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'having clause' (SQL: select count(*) as aggregate from `directories` having `distance` < 100) -- Β 

newBaseQueryBuilder Error

Hi,

Thanks for this awesome package. It works great however there is a conflict with another package that I am using.
https://github.com/jarektkaczyk/eloquence

When I add trait I get the following error.

Trait method newBaseQueryBuilder has not been applied, because there are collisions with other trait methods

The following method fixes the problem but in that case, I cant use Sofa/Eloquence

    use PaginationWithHavings,Eloquence{
        PaginationWithHavings::newBaseQueryBuilder insteadof Eloquence;
    }

Any idea how to fix it?

Doesn't work with "withCount"

Hello!
Laravel 5.8
In this case it does not work.

pays its a hasManyThrough relation.

 $orders->withCount(['pays as pay_sum' => function (Builder $q) {
                        return $q->select(DB::raw('SUM(invoice_pays.sum)'));
                    }])->havingRaw('pay_sum >= `orders`.`amount`');

Column not found: 1054 Unknown column 'orders.amount' in 'having clause'

But of course such a column exists. Everything works well without pagination.

Laravel 8.0

Could we please make the updates needed to support Laravel 8.0?

Thanks for the package πŸ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.