The Earmark Laravel package by Brian LaVallee generates values in a unique and customizable series:
A Laravel package to earmark sequential values in a series and eliminate any gaps in the series when values are unset. Allowing for reusable values.
It can be used to fetch the next value (or array of values) to be used in an application. Database locking prevents duplicate values from being returned.
Here’s some basic usage examples from the package’s readme:
First, you can get and unset (for reuse) values:
$serial = Earkmarked::get(); // Returns: '2010' Earkmarked::unset($serial);
You can also specify the number of values to return:
// Returns: ['2011', '2012', '2013'] $serial = Earkmarked::get(3); Earkmarked::unset($serial);
A more advanced example, including configurable variables:
Filed in: News
// Earmark(prefix, suffix, padding, min, max) $earmark = new Earmark('ZULU', null, 10, 5000, null); // Returns: 'ZULU0000005000' $earmark->get(); // Returns: ['ZULU0000005001', 'ZULU0000005002', 'ZULU0000005003'] $earmark->get(3);
- Backend Software Engineer (PHP Developer)
Austin TX, Bonita Springs FL
Certified eSupport Corp
- Backend PHP Developer
ABOUT YOU GmbH
- Full-Stack Engineer (Mid to Senior)
Remote (EST, CST)
- Senior Laravel Developer (AI Applications)
Remote from anywhere in the UK or from our London office
- Full Stack Engineer
Join 31,000+ others and never miss out on new tips, tutorials, and more.