Download the PHP package creativecrafts/laravel-secure-random-number-generator without Composer

On this page you can find all versions of the php package creativecrafts/laravel-secure-random-number-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-secure-random-number-generator

laravel-secure-random-number-generator

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

A handy package to generate a secure unique random number for a model.

Installation

You can install the package via composer:

You can publish the config file with:

This is the contents of the published config file:

Usage

New Features

The Laravel Secure Random Number Generator package has been enhanced with several new methods and trait to provide more flexibility and functionality when generating secure random numbers.

New Methods

Batch Generation

Formatted Numbers

Pattern-Based Numbers

Batch Formatted Numbers

Batch Pattern-Based Numbers

Range Customization

Uniqueness Validation

Usage

Generating Multiple Random Numbers

Generating Formatted Numbers

Generating Multiple Formatted Numbers

Generating Multiple Pattern-Based Numbers

Customizing Number Range

Ensuring Uniqueness in Database

Fluent Interface

All methods can be chained for a fluent interface:

Error Handling

The batch generation methods will throw a RuntimeException if they cannot generate the requested number of unique values after a reasonable number of attempts. Make sure to handle this exception in your code:

Trait

HasSecureRandomNumber

This trait provides an easy way to automatically generate and assign secure random numbers to your Laravel Eloquent models.

Usage

Basic Usage

Add the trait to any Eloquent model where you want to automatically generate a secure random number:

By default, the trait will: -Generate a secure random number when creating a new model instance -Store the number in a column named reference_number -Use the default number range from the package configuration

Customizing the Column Name

If you want to use a different column name for storing the random number, define the $randomNumberColumn property in your model:

Database Migration

Make sure to include the appropriate column in your migration:

Manually Generating Random Numbers

You can also manually generate a random number for a model:

How It Works The trait:

  1. Registers a creating event listener on the model
  2. When a new model is being created, it checks if the random number column is empty
  3. If empty, it generates a secure random number that is unique within the model's table
  4. Assigns the generated number to the specified column

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

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.


All versions of laravel-secure-random-number-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3|^8.2
spatie/laravel-package-tools Version ^1.19
illuminate/contracts Version ^12.0|^11.0|^10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package creativecrafts/laravel-secure-random-number-generator contains the following files

Loading the files please wait ....