Skip to content
Advertisement

Laravel – unsigned with nullable

I am using Laravel 5.3, I want to define a field in table migration as nullable as well as unsigned. As both are index modifier, can I use them in concatenation ? Like:

JavaScript

Please also give some reference if there is to these kind of modifications in laravel documentation or somewhere.

Please note that I want to define field in up() function as unsigned as well as nullable. I dont want solutions with down() function like:

JavaScript

Thanks in advance!

Advertisement

Answer

You can. Laravel allows a lot of method-chaining. Each of the column methods is defined to return the same Blueprint object, so you can easily call another method on it. This means you could even do:

JavaScript

And all would be well 🙂

For further information, see the documentation on database migrations (see the section on “Column Modifiers”).

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement