Skip to content

omaressaouaf/laravel-id-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel ID Generator

Latest Stable Version License Tests

A Laravel package for generating custom auto-incrementing IDs with prefixes, suffixes, and date-based placeholders.

🚀 Features

  • Auto-increment ID generation for any column.
  • Allow custom prefixes & suffixes & padding
  • Supports {DATE}, {MONTH}, and {YEAR} placeholders.

📥 Installation

Install via Composer:

composer require omaressaouaf/laravel-id-generator

📌 Usage

Basic Example

Generate an ID with a prefix and suffix and padding:

use Omaressaouaf\LaravelIdGenerator\IdGenerator;
use App\Models\User;

$id = IdGenerator::generate(Invoice::class, 'column_name', 5, 'INV-', '-2024');

echo $id; // INV-00001-2024

Dynamic Placeholders

  • {DATE}2025-02-28
  • {MONTH}2025-02
  • {YEAR}2025
$id = IdGenerator::generate(Invoice::class, 'column_name', 5, 'INV-{YEAR}-');
echo $id; // INV-2025-00001

🛠️ Testing

Run unit tests:

composer test

📜 License

This package is licensed under the MIT License.