Down with string literals! How to avoid repeating myelf?

Viewed 30

Is there an approved way of dealing with string literals in Laravel code? I'll explain a bit.

If I have a model, backed by a db, then I have the names of my table's columns as string literals in the migration file for that table. Then I have (some of) those same literals repeated in $fillable in the model. And again in the code, wherever I put it, that creates model objects and pushes the data to the db. And so on.

I'm new to Laravel, so I was wondering: is there an approved way of repeating myself constantly?

0 Answers
Related