vendredi 12 octobre 2018

Laravel Eloquent : Set custom formatted ID in Table

Is there any way where I can add custom formatted ID on create?

for example, there is a table 'Customers', in this table there are one primary key - 'ID (auto increment)' and one unique key 'customer_id'

Now, when I will create a new customer, the 'ID' is auto increment so it will automatically set in DB.

I want to set 'customer_id' like '2018-0001' at the time of create. CurrentYear-000 INSERTED_ID



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire