Generate trends for your models. Easily generate charts or reports.

Overview

Laravel Trend

Generate trends for your models. Easily generate charts or reports.

Support us

Like our work? You can support us by purchasing one of our products.

Installation

You can install the package via composer:

composer require flowframe/laravel-trend

Read more on our documentation website.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Support cumulative totals

    Support cumulative totals

    As well as totals per period, it would be good to group data by the cumulative total until that period. e.g. total users over time per period, as well as total new users per period.

    opened by kurucu 1
  • Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column

    Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column

    Having the following code:

            $data = Trend::model(User::class)
                ->between(now()->subWeek(), now()->endOfDay())
                ->perDay()
                ->count();
    

    Generates the error:

    Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
    
    opened by Cannonb4ll 1
  • Laravel 9 support

    Laravel 9 support

    Hello @Larsklopstra!

    This PR allows the package to be installed in Laravel 9. Additionally, it updates the test suite for running on PHP 8.1 and Laravel 9.

    The minimum required version of Laravel is now 8.71 (because early versions of Laravel 8 don't support PHP 8.1).

    Resolves: #5

    opened by pktharindu 1
  • Laravel 9 support.

    Laravel 9 support.

    Hey,

    First of all thx for the great package.

    I'm upgrading some Laravel applications that use this package to Laravel 9. but when i run composer update it triggers soms errors.

    Error:

    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Root composer.json requires flowframe/laravel-trend ^0.0.2 -> satisfiable by flowframe/laravel-trend[v0.0.2].
        - Conclusion: don't install laravel/framework v9.0.0-beta.2 (conflict analysis result)
        - Conclusion: don't install laravel/framework v9.0.0-beta.3 (conflict analysis result)
        - Conclusion: don't install laravel/framework v9.0.0-beta.4 (conflict analysis result)
        - Conclusion: don't install laravel/framework v9.0.0-beta.5 (conflict analysis result)
        - Conclusion: don't install laravel/framework v9.0.0 (conflict analysis result)
        - Conclusion: don't install laravel/framework v9.0.1 (conflict analysis result)
        - Conclusion: don't install laravel/framework v9.0.0-beta.1 (conflict analysis result)
        - flowframe/laravel-trend v0.0.2 requires illuminate/contracts ^8.37 -> satisfiable by illuminate/contracts[v8.37.0, ..., 8.x-dev].
        - Only one of these can be installed: illuminate/contracts[dev-master, v5.4.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev], laravel/framework[v9.0.0-beta.1, ..., 9.x-dev]. laravel/framework replaces illuminate/contracts and thus cannot coexist with it.
        - Root composer.json requires laravel/framework ^9.0 -> satisfiable by laravel/framework[v9.0.0-beta.1, ..., 9.x-dev].
    
    Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
    
    opened by Tjoosten 0
  • Sorting problems

    Sorting problems

    There's something weird going on with sorting. Because we're also support perYear we can't use integers as keys, that's why we use data objects. However, they're not being sorted after the data and placeholder data has been merged.

    The proposed solutions are:

    • Rethink merging strategy
    • Do another sort on the collection
    • Ditch perYear
    bug 
    opened by Larsklopstra 0
  • issue when model contains

    issue when model contains "date" column (conflicts with date_format alias)

    I have a model for transactions that includes these two fields:

    • date: when did the transaction take place
    • created_at: when was the record created

    This results in an error message:

    Illuminate\Database\QueryException  SQLSTATE[42000]: 
    Syntax error or access violation: 1055 'myapp.transactions.created_at' isn't in GROUP BY
    

    Using e.g.

    Flowframe\Trend\Trend::model(Transaction::class)
    ->between(start: now()
    ->subMonths(1), end: now())
    ->perMonth()
    ->count()
    

    which "expands" to:

    select 
      date_format(created_at, '%Y-%m') as date, -- this alias conflicts with the table's column `date`
      count(*) as aggregate
    from `transactions` 
    where `created_at` between '2022-10-09 18:48:11' and '2022-11-09 18:48:11'
    group by `date` 
    order by `date` asc
    

    It seems the date_format(...) as date conflicts with the table column date.

    The above works fine for a model without a date column.

    Related: can the field to group by be customized? I don't want to group by created_at but group by the table's column date instead.

    opened by wivaku 0
  • Timezone support

    Timezone support

    The method convertTimezone adds the ability to aggregate in a different timezone than the timezone of the database (closes #19):

    $trend = Trend::model(...)
        ->between(...)
        ->perMonth()
        ->convertTimezone(
            from: 'UTC',
            to: 'Europe/Amsterdam',
        )
        ->count();
    

    Unfortunately, I couldn't find a way to convert the timezone for SQLite and therefore implemented an error message in that case. Additionally, I wasn't able to test these changes in pgSQL. Could please somebody verify the changes on a pgSQL database?

    opened by bohemianoid 0
  • Placeholders with custom date format

    Placeholders with custom date format

    The new placeholders method allows to get the placeholders as a collection in a custom date format for further use in diagrams and reports:

    $trend = Trend::model(...)
        ->between(...)
        ->perDay();
    
    $placeholders = $trend->placeholders('D');
    $totals = $trend->count();
    

    Please let me know if a can support you in any way to merge these changes and thanks for your work. :tada:

    opened by bohemianoid 0
  • Invalid column reference when trying to fetch distinct column

    Invalid column reference when trying to fetch distinct column

    Problem description

    When trying to retrieve unique attendees of an event. I'm using this query:

    Attendee::query()->distinct('user_id')
    

    It works on its own but when using it in this chart widget;

    Trend::query(Attendee::query()->distinct('user_id'))
                ->between(
                    start: now()->setDate(2021, 1, 1),
                    end: now(),
                )
                ->perMonth()
                ->count();
    

    I get this error:

    SQLSTATE[42P10]: Invalid column reference: 7 ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions LINE 1: select distinct on ("user_id") ^ (SQL: select distinct on ("user_id") to_char(created_at, 'YYYY-MM') as date, count(*) as aggregate from "attendees" where "created_at" between 2021-01-01 16:43:04 and 2022-10-14 16:43:04 group by "date" order by "date" asc)
    
    opened by humaneguy 0
  • Add betweenTimestamp() function

    Add betweenTimestamp() function

    Sometimes, we store timestamp in database as UNIX Timestamp not Y-m-d H:i:s format, so I create betweenTimestamp() function to support it and do some adjustment in Adapters and Trend class.

    opened by ijalnasution 0
Releases(v0.1.1)
  • v0.1.1(Feb 25, 2022)

    What's Changed

    • Sort DatePeriod after merge and unique by @Wit3 in https://github.com/Flowframe/laravel-trend/pull/4

    New Contributors

    • @Wit3 made their first contribution in https://github.com/Flowframe/laravel-trend/pull/4

    Full Changelog: https://github.com/Flowframe/laravel-trend/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Feb 10, 2022)

    What's Changed

    • Laravel 9 support by @pktharindu in https://github.com/Flowframe/laravel-trend/pull/6

    New Contributors

    • @pktharindu made their first contribution in https://github.com/Flowframe/laravel-trend/pull/6

    Full Changelog: https://github.com/Flowframe/laravel-trend/compare/v0.0.2...v0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(Nov 1, 2021)

    What's Changed

    • Support PostgreSQL by @tombenevides in https://github.com/Flowframe/laravel-trend/pull/2

    New Contributors

    • @tombenevides made their first contribution in https://github.com/Flowframe/laravel-trend/pull/2

    Full Changelog: https://github.com/Flowframe/laravel-trend/compare/v0.0.1...v0.0.2

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Oct 7, 2021)

Owner
Flowframe
Flowframe is a web agency specialised in creating delightful web experiences combined with a solid back-end.
Flowframe
Laravel component to create gorgeous Charts.css charts.

Laravel component to create gorgeous Charts.css charts. This package will help you generate CSS only charts based on the Charts.css library. Installat

Maarten Paauw 105 Sep 26, 2022
Charts - a Laravel library used to create Charts using Chartisan

Charts is a Laravel library used to create Charts using Chartisan. Chartisan does already have a PHP adapter. However, this library attempts to provide more laravel-like features into it by providing support for chart creation using the artisan command, middleware support and routing support.

Mohammad 2 Mar 14, 2022
Laravel charts is a package to simplify the use of charts.

Laravel Charts Laravel charts is a package to simplify the use of charts. Features Autoregister your charts Customize routing, middleware and prefix t

Datalogix 2 Aug 5, 2022
Opensource tinyman charts software

This software is live at https://freetinycharts.ovh How-to install: In a linux box with apache,php & mysql, as root: Unpack zip mkdir /scripts/ cp *.p

Pablo Manuel Castelo Vigo 14 Dec 8, 2022
A Laravel wrapper for apex charts

Larapex Charts A Laravel wrapper for apex charts library Check the documentation on: Larapex Chart Docs. Installation Use composer. composer require a

ArielMejiaDev 189 Dec 26, 2022
This package allows you to easily work with NanoID in your Laravel models.

Laravel Model UUIDs Introduction Huge thanks to Micheal Dyrynda, whose work inspired me to create this package based on laravel-model-nanoid but uses

Parables Boltnoel 3 Jul 27, 2022
Easily add all the 58 Algerian Wilayas and its Dairas to your cool Laravel project (Migrations, Seeders and Models).

Laravel-Algereography Laravel-Algereography allows you to add Migrations, Seeders and Models of Algerian Wilayas and Dairas to your existing or new co

Hocine Saad 48 Nov 25, 2022
The package lets you generate TypeScript interfaces from your Laravel models.

Laravel TypeScript The package lets you generate TypeScript interfaces from your Laravel models. Introduction Say you have a model which has several p

Boris Lepikhin 296 Dec 24, 2022
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.

Laravel-Mediable Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel. Features Filesystem-driven appro

Plank Design 654 Dec 30, 2022
🏭 An easy way to generate populated factories for models.

Laravel Populated Factory provides an easy way to generate populated factories for models according to types & names of their columns. Install You can

Coderello 241 Nov 25, 2022
A package to generate YouTube-like IDs for Eloquent models

Laravel Hashids This package provides a trait that will generate hashids when saving any Eloquent model. Hashids Hashids is a small package to generat

Λгi 25 Aug 31, 2022
Generate previous attributes when saving Eloquent models

This package provides a trait that will generate previous attributes when saving any Eloquent model.

Ricardo Sawir 33 Nov 6, 2022
Easily generate URLs to Minecraft avatars with the ability to switch between services

Minecraft Avatar URLs This library provides PHP utilities to generate URLs to Minecraft Avatars in different formats with the ability to easily change

Gigadrive UG 3 Aug 11, 2022
Easy creation of slugs for your Eloquent models in Laravel

Eloquent-Sluggable Easy creation of slugs for your Eloquent models in Laravel. NOTE: These instructions are for the latest version of Laravel. If you

Colin Viebrock 3.6k Dec 30, 2022
Use auto generated UUID slugs to identify and retrieve your Eloquent models.

Laravel Eloquent UUID slug Summary About Features Requirements Installation Examples Compatibility table Alternatives Tests About By default, when get

Khalyomede 25 Dec 14, 2022
A Laravel package making a diagram of your models, relations and the ability to build them with it

Laravel Schematics This package allows you to make multiple diagrams of your Eloquent models and their relations. It will help building them providing

Maarten Tolhuijs 1.4k Dec 31, 2022
A Laravel Code Generator based on your Models using Blade Template Engine

Laravel Code Generator is a PHP Laravel Package that uses Blade template engine to generate code for you. The difference between other code generators

Victor Yoalli 59 Dec 5, 2022
A simple drop-in solution for providing UUID support for the IDs of your Eloquent models.

Introduction A simple drop-in solution for providing UUID support for the IDs of your Eloquent models. Both v1 and v4 IDs are supported out of the box

GoldSpec Digital 501 Jan 4, 2023
Kalibrant - a package that provides a simple way to manage your models settings

Introduction For your laravel 9.x applications, Kalibrant is a package that provides a simple way to manage your models settings. It is a simple way t

Starfolk 3 Jun 18, 2022