Support the ongoing development of Laravel.io →
posted 4 years ago
Laravel
Last updated 2 years ago.

meenctg liked this thread

1

Hello Meen,

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

https://laravel.com/docs/6.x/eloquent-mutators

Hope it help ;)

0

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 4 years ago.

meenctg liked this reply

1

Thank you very much @farukaziz

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Meen meenctg Joined 15 Mar 2020

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.