What type of data in the migrations should be set for:

1) INTEGER listing 1,2,3,4

2) String listing images/1.jpg,images/2.jpg,images/3.jpg

In the first case, I will store id records, in the second case, links to images.

Now I use $table->string();

But something tells me that I am going the wrong way. Thank.

  • Storing data in a database, separated by commas, is a bad practice (with rare exceptions). Achieve such a result that one ID matches one or more pictures. One match - one picture. - neluzhin

1 answer 1

With types according to your description, everything is fine, write id in primary (). If in doubt, try using the migration generator.
https://github.com/laracasts/Laravel-5-Generators-Extended ,
however, it works only for existing tables, but it will help

  • The answer is not at all related to the question. - neluzhin