#Eloquent or sqlRaw scope advice

9 messages · Page 1 of 1 (latest)

hallow pewter
#

The easiest solution is probably to add a latestVisit relationship on user, using hasOne()->latestOfMany(). Then you can just call with ('latest_visit')

hallow pewter
#

Oh okay, I misunderstood. Then I would make the scope something like "where id is in(subquery selecting MAX(id) grouped by user_id)"

hallow pewter
#

Is it too late to switch to a normal incrementing primary key? You can still have a uuid column, but integers make life a lot easier. And faster (at least on MySQL, don't know if it's different with postgres)

wary crater
#

sid help me pls

#

@hallow pewter can you help me woth this error pls (The GET method is not supported for this route. Supported methods: POST.)

#

ok

hallow pewter
#

Yeah you could have both 'id' (normal incrementing, PK) and a 'uuid' column (indexed). You don't have to expose the id column to the outside world.

#

There are a few ways you can make route model binding use uuid in stead of id.

hallow pewter
#

I don't know enough about the models to answer that.