ankane/hightop

A nice shortcut for group count queries with Eloquent / Laravel

v0.1.0 2022-08-23 02:30 UTC

This package is not auto-updated.

Last update: 2024-05-01 08:40:40 UTC


README

A nice shortcut for group count queries with Eloquent / Laravel

Visit::top('browser');
// [
//   'Chrome' => 63,
//   'Safari' => 50,
//   'Firefox' => 34
// ]

Build Status

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:

To get started with development:

git clone https://github.com/ankane/hightop-php.git
cd hightop-php
composer install
composer test