Support the ongoing development of →
Last updated 2 weeks ago.

Hello Meen,

I don't know if you have ever heard about mutators and accessors but it seems what you need.

Hope it help ;)


You can use Laravel ID generator package. This package is really simple to use and generate custom ID without any complexity.

For generate id like CUST-00001, CUST-00002 use

$id = IdGenerator::generate(['table' => 'customers', 'length' => 10, 'prefix' =>'CUST-']);

// output CUST-00001, CUST-00002, CUST-00003, ......

For generate id like P-0001, P-0002, M-0001, M-0002 use

$id = IdGenerator::generate(['table' => 'products', 'length' => 6, 'prefix' => $prefix,'reset_on_prefix_change'=>true]);

//output: P-0001, P-0002, M-0001, M-0002, .....

Hope it help :)

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?

Meen Meen meenctg Joined 15 Mar 2020


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 - All rights reserved.