girover/sequent-numbers

Generating database table for Sequent Numbers as strings

v0.1.0-alpha 2022-07-09 16:38 UTC

This package is not auto-updated.

Last update: 2024-11-13 05:11:05 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Content

Introduction

girover/sequent-numbers is a package for generating sequence of numbers.
And possibility of storing them in database.

Prerequisites

  • Laravel 8+
  • PHP 8+
  • Mysql 5.7+

Installation

You can add the package via composer:

composer require girover/sequent-numbers

Before installing the package you should configure your database.

Usage

getting set of numbers

To make a set of numbers in memory, you can do this.

   // InAController
   use \Girover\SequentNumbers\Numbers;

   $numbers = new Numbers;

   $numbers->from('00000')->to('99999')->get()
   // This will return Illuminate\Database\Eloquent\Collection

To add some constraints on your numbers:

   // InAController
   use \Girover\SequentNumbers\Numbers;

   $numbers = new Numbers;
   $numbers->from("0000")->to("9999");
   $numbers->query()->where('number', '>', '1000')->get();
   // This will return Illuminate\Database\Eloquent\Collection
   
   $numbers->query()->whereBetween('number', ["5555","7777"])->get();
   // This will return Illuminate\Database\Eloquent\Collection

Storing Numbers in Database

To store your created numbers in the database, you can do this:

   // InAController
   use \Girover\SequentNumbers\Numbers;

   $numbers = new Numbers;
   $numbers->from("0000")->to("9999");

   $numbers->storeInTable('my_numbers_table');

Note: If the name of table already exists in database, the table should has a column called 'number' with varchar(255) type.