davy_yg's avatar
Level 27

index vs show

Check this ref: https://laravel.com/docs/6.x/controllers#restful-naming-resource-routes

What is the difference between action index and action show? Is both showing the same tables?

0 likes
5 replies
Tray2's avatar

The index shows all entries in a table while the show only shows one specific entry.

1 like
davy_yg's avatar
Level 27

Why would you see one specific item only? Is it to check the detail of an item? Is it in form of tables or form?

Tray2's avatar
Tray2
Best Answer
Level 73

Let's say you have a table of books.

On the index page you show information like

  • Title
  • Author
  • Series
  • Format
  • Publication year

Then if you click on one of the books in the list you get more informtion about the book, like

  • Isbn
  • Blurb
  • Number of pages
  • List of reviews
  • and so on

The same would go for a record collection.

Or as here on Laracasts Forum

You have an index showing all the threads and a show showing the full question and all the answers to it.

You should use it when you want to display more information about a record in the database.

The index is most likely a table yes. The show is usually not a table and it's not a form either. Forms are reserved for create and update views.

1 like
davy_yg's avatar
Level 27

So show would be a list of information from one record?

Please or to participate in this conversation.