Download the PHP package rorecek/laravel-autoincrement without Composer
On this page you can find all versions of the php package rorecek/laravel-autoincrement. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rorecek/laravel-autoincrement
More information about rorecek/laravel-autoincrement
Files in rorecek/laravel-autoincrement
Package laravel-autoincrement
Short Description Set table AUTO_INCREMENT values in your Laravel application
License MIT
Homepage https://github.com/rorecek/laravel-autoincrement
Informations about the package laravel-autoincrement
Laravel AutoIncrement
This package will help you set table AUTO_INCREMENT values in your Laravel application.
Why do you need to change auto-increment values?
If you do not change auto-increment values of your tables you are exposing
how many records you have in there. Imagine some user makes an order and
is redirected to this order detail URL https://example.com/orders/10
.
User will know then that there are only 10 orders in the whole system which
is probably information you do not want to share. If you will change your
table to start with a higher auto-increment number, for example, 512322,
it will not be that obvious (https://example.com/orders/512332
).
But what if he makes another order month from now? There will be only small difference between these numbers and anyone can easily calculate your monthly activity. There is an easy solution for this. Add auto-increment update toLaravel's command scheduler and add some random number to your next auto-increment id automatically on hourly, daily, monthly, etc., basis.
What are the benefits?
-
Integer values are way more efficient than UUIDs or other types of string ids
-
Sorting by id still leads to chronological order
- You do not expose the total number of resources in your database, for example
https://example.com/users/10
Installation
You can install this package via composer using this command:
Usage
You can use this package to set the next auto-increment id to a specific value, or to add a number to current value or to reset auto-increment to the lowest possible value.
Migrations
Set auto-increments directly in your migrations.
Scheduler
Setup automatic auto-increment increases using task scheduler.
Advanced usage
You can optionally use different connections and/or closures if needed.
Support
If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request.
If you're using this package, I'd love to hear your thoughts. Thanks!
License
The MIT License (MIT). Pavel Rorecek