Laravel: Data to Monthly Converter

Related tags

Laravel Data2Monthly
Overview

Laravel: Data to Monthly Converter

Using this package you will be able to converts your collection using a timestamp field to order data monthly or yearly and calculate monthly/yearly expenses. You can use this package to build some expenses app and apply in chart.js efficiently.

Require this package in your composer.json and update composer.

composer require 101infotech/data2monthly

Code Examples

use Infotech\Data2Monthly\Monthly;

To get a ordered monthly data upto current month.

$data = Visitors::all();
Monthly::current($data,'created_at'));

// $data must be a Collection
// 'created_at' exist in collection, holds a timestamp or date

Result: It counts the data found on the respective month and returns an array.

array:5 [▼
  0 => 0
  1 => 0
  2 => 0
  3 => 0
  4 => 1
]

To get a sum of a field grouped monthly.

$data = Expenses::all();
Monthly::expenseMonthly($data,'created_at','price');

Result: It sums all the 'price' field and group monthly.

array:12 [▼
  0 => 150
  1 => 900
  2 => 300
  3 => 600
  4 => 300
  5 => 450
  6 => 0
  7 => 0
  8 => 0
  9 => 0
  10 => 0
  11 => 0
]

To get a data counted monthly data upto current month according to a given year.

$data = Expenses::all();
Monthly::currentWithYear($data,'created_at','price','2021'));

Result: It counts the data found on the respective month upto current month and with respective year and returns an array.

array:6 [▼
  0 => 0
  1 => 0
  2 => 0
  3 => 0
  4 => 2
  5 => 0
]

Some List of Available Codes

Monthly::current($data,'created_at'));
Monthly::monthly($data,'created_at'));
Monthly::yearly($data,'created_at'));
Monthly::expenseCurrent($data,'created_at','price'));
Monthly::expenseMonthly($data,'created_at','price));
Monthly::expenseYearly($data,'created_at','price'));
Monthly::currentWithYear($data,'created_at','price','2021'));
Monthly::monthlyWithYear($data,'created_at','price','2021'));

Using in chart.js

$dataArr = Monthly::current($data,'created_at'));

You might also like...
Laravel 5 Repositories is used to abstract the data layer, making our application more flexible to maintain.

Laravel 5 Repositories is used to abstract the data layer, making our application more flexible to maintain.

Laravel package to normalize your data before saving into the database.

This package helps you normalize your data in order to save them into the database. The Goal is to having separate classes that handle the data normalization, and thus can be tested independently.

Laravel 5.* package to easily introduce a transformation layer for your data

Laraformer Laraformer is a laravel 5.* package that lets you easily introduce a transformation layer for your data. Laraformer (originated from Larave

A laravel package to access data from the Strava API.

Laravel Strava Package A laravel package to access data from the Strava API. Compatible with Laravel 5.0 and above. Table of Contents Strava Access Cr

Postier is a Laravel API automation platform to transfer data and to sync apps.
Postier is a Laravel API automation platform to transfer data and to sync apps.

Postier is a Laravel API automation platform to transfer data and to sync apps. You can build workflows with data and actions of multiple apps and apply logics to the data!

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

A Laravel package to fetch Open Graph data of a website.
A Laravel package to fetch Open Graph data of a website.

OpenGraph is a laravel package to fetch Open Graph metadata of a website/link. Features Easily fetch metadata of a URL. Laravel OpenGraph fetches all

Laravel package to work with geospatial data types and functions.

Laravel Spatial Laravel package to work with geospatial data types and functions. For now it supports only MySql Spatial Data Types and Functions. Sup

LaravelFly is a safe solution to speeds up new or old Laravel 5.5+ projects, with preloading and coroutine, while without data pollution or memory leak

Would you like php 7.4 Preloading? Would you like php coroutine? Today you can use them with Laravel because of Swoole. With LaravalFly, Laravel will

Releases(v1.2)
Owner
101INFOTECH
Web Development Team
101INFOTECH
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. B

Tenancy 2.4k Jan 3, 2023
Collection of the Laravel/Eloquent Model classes that allows you to get data directly from a Magento 2 database.

Laragento LAravel MAgento Micro services Magento 2 has legacy code based on abandoned Zend Framework 1 with really ugly ORM on top of outdated Zend_DB

Egor Shitikov 87 Nov 26, 2022
Save Model is a Laravel package that allows you to save data in the database in a new way.

Save Model is a Laravel package that allows you to save data in the database in a new way. No need to worry about $guarded and $fillable properties in the model anymore. Just relax an use Save Model package.

Laratips 27 Mar 2, 2022
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.

Tenancy for Laravel Enabling awesome Software as a Service with the Laravel framework. This is the successor of hyn/multi-tenant. Feel free to show su

Tenancy 1.1k Dec 30, 2022
A laravel package to handle sanitize process of model data to create/update model records.

Laravel Model UUID A simple package to sanitize model data to create/update table records. Installation Require the package using composer: composer r

null 66 Sep 19, 2022
Interact with TMDB data in your Laravel application.

Laravel TMDB Installation composer require astrotomic/laravel-tmdb php artisan vendor:publish --tag=tmdb-migrations Configuration Add your TMDB API v4

Astrotomic 32 Dec 21, 2022
Convert remote api response data into laravel model

laravel remote model Create remote driver to convert remote api request into laravel model. 中文文档 日本語文書 overview Install the version between laravel5.5

张子彬 15 Aug 11, 2022
Laravel Grid is a package that helps you display table data.

Laravel Grid Laravel Grid is a package that helps you display table data. I could not find package that would satisfy my needs so I decided to write o

null 9 Nov 29, 2022
Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Ogundiran Adewale Charles 2 Jul 27, 2022
Collection of classes you can use to standardize data formats in your Laravel application.

Laravel Formatters This package is a collection of classes you can use to standardize data formats in your Laravel application. It uses the Service Co

Michael Rubel 88 Dec 23, 2022