BKWLD / decoy

A Laravel model-based CMS
http://docs.decoy.bukwild.com/
MIT License
303 stars 44 forks source link

Timestamps on model mandatory? #58

Closed eminos closed 7 years ago

eminos commented 7 years ago

I don't have timestamps on this one model/table, and I'm getting this error trying to view the model in admin:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'slides.created_at' in 'order clause' (SQL: select * from `slides` order by `slides`.`position` asc, `slides`.`created_at` desc limit 20 offset 0)

I have this in the model:

public function scopeOrdered($query)
    {
        $query->positioned();
    }

Am I missing something? Are the timestamps mandatory when using Decoy?

weotch commented 7 years ago

No, though that positioned scope does expect them: https://github.com/BKWLD/decoy/blob/master/classes/Models/Base.php#L581-L591. To fix, in your model, override the positioned scope method and just have it use the position column. Make sense?

weotch commented 7 years ago

Actually, I should have that method check whether you are using timestamps or not...