Hightop PHP
A nice shortcut for group count queries with Eloquent / Laravel
Visit::top('browser');
// [
// 'Chrome' => 63,
// 'Safari' => 50,
// 'Firefox' => 34
// ]
Installation
Run:
composer require ankane/hightop
Options
Limit the results
Visit::top('referring_domain', 10);
Include null values
Visit::top('search_keyword', null: true);
Works with expressions
use Illuminate\Database\Query\Expression;
Visit::top(new Expression('lower(referring_domain)'));
And distinct
Visit::top('city', distinct: 'user_id');
And min count
Visit::top('city', min: 10);
And where
clauses
Visit::where('browser', 'Firefox')->top('os');
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/hightop-php.git
cd hightop-php
composer install
composer test