1 month ago

How to use generatedAs migration modifier

Posted 1 month ago by pjstew

I can seem to find any information on how to actually use generatedAs($expression) column modifier.

Does anyone know how it works?

What i'm after doing is creating a unique string from an array of word each time a model is created.


Let say I have a user model, each time a user is created, I want to create a string that contains 4 word from a defined array.

let say the array is ['this', 'is', 'the', 'array']

then it would create a unique string, such as: 'the array is this'.

Obviously this is a contrived example, but hopefully explains the feature.

The array I'm actually working with has about 45 word in it and it's not actually for the user model.

I realise that generatedAs might not be the way to go, so any suggestion welcome!

Thanks in advanced! ;-)

Please sign in or create an account to participate in this conversation.