Voyager: Browse error if table doesn't have timestamps

Created on 26 Apr 2017  路  11Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.4.19
  • Voyager Version: 0.11.9
  • PHP Version: 5.6.29
  • Database Driver & Version: MySQL 5.7.17

Description:

If I create table without timestamps and than try to browse it get an error
QueryException in Connection.php line 647: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in 'order clause' (SQL: select * from bookings order by created_at desc)

It could useful to add an option to BREAD creation, which adds public $timestamps = false; to the model.

Steps To Reproduce:

  1. Create table
  2. Add BREAD to the table
  3. Browse table
possible bug

Most helpful comment

This may not be an issue after all. I'm still new to Laravel and am working with a legacy database. When I added public $timestamps = false; to the model, the problem went away.

All 11 comments

@timbertlt then why don't you just add created_at to your table, so it's not causing error.

@endrureza because I don't need such type of fields in this table. It's not a problem to add $timestamps = false to the table, but anyway it's make sense to have this option or add timestamps by default.

I'm also seeing this issue. The table I've created is solely for storing dropdown list data used elsewhere in the admin dashboard so I have no need for created & updated data.

Labels: enhancement, possible bug

Closing since 1.0 is released. If this is still an issue in 1.0, please provide steps to reproduce the error in 1.0 and we'll reopen it.

This is still an issue in 1.0.5. I clicked "Add BREAD to this table" for a table without timestamps, left all of the fields the way they were, clicked "Submit", gave the "admin" role all permissions for the table, and then clicked the "Browse BREAD" button. This is what I got:

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

This may not be an issue after all. I'm still new to Laravel and am working with a legacy database. When I added public $timestamps = false; to the model, the problem went away.

Edited: @ataylor32 solution's could have been the solution to the original problem.

It was never reopened

Sorry I didn't saw, I would say that his solution simply work.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaggelis2018 picture vaggelis2018  路  3Comments

winex01 picture winex01  路  3Comments

rayqiri picture rayqiri  路  3Comments

TXRRNT picture TXRRNT  路  3Comments

Nagendra1421 picture Nagendra1421  路  3Comments