voyager: Error with BREAD > Browse if column created_at was not created

Version information

  • Laravel: v5.7
  • Voyager: v1.1
  • PHP: 7.1.3
  • Database: MySQL 5.6

Description

BREAD > Browse sorts by created_at by default. If this column was not created, an error occurs.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in 'order clause' (SQL: select * from exampleorder bycreated_at desc)

Steps To Reproduce

Steps to reproduce the behavior:

  1. Go to Tools > BREAD
  2. Click on Browse
  3. See the error if the column created_at was not created for the table.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

This is correct, but then this field must always be created when a model is created for the table. Or a warning should appear when creating the tables.

btw: thank you for the prompt response

Well, the problem for me is that when you do the following:

  1. create new table from Admin
  2. add BREAD from Admin
  3. navigate to the new table You get the mentioned error which is quite nasty to see. I can see that in the Create new table form there is an ‘Add timestamp’ button which is very handy, but it should be more clear that if you don’t add timestamps manually or add some code to the model then the application is going to break. What about automatically adding public $timestamps = false; in any model without timestamps? This would prevent the nasty error.