Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does index()" mean in Laravel?

I have this code $table->integer('card_id')->unsigned()->index(); in a table that I created using Laravel framework. Just to make sure what does the index()?

like image 630
Van Adrian Cabrera Avatar asked May 20 '16 15:05

Van Adrian Cabrera


1 Answers

It's the way to say to the Laravel Migration to add indices to that column, in order to get faster results when searching through that particular column.

It's a common procedure in DB design when building tables. Just "index" some particular columns if you plan to make searchs in the table using those columns.

I just realized you added that "indexing" tag to your question and that the description of that tag answers your question.

like image 119
Amarnasan Avatar answered Oct 09 '22 20:10

Amarnasan