first()/firstOrFail() with non-unique names - am I safe that I'll get the correct row?
When a user creates an account, a default folder named "main" is created for him. But the name is not unique and he can create more folders named "main".
And in one of my Controllers, I use the firstOrFail() method that's supposed to get the default "main" folder:
Am I safe that it will always get the initially created "main" folder (Which will have the lowest id in the DB table for that user)? Or I should use a different query to make sure?
Well, to be honest, I would simply add a flag column to the table called "main", set to true only for the default "main", this way you are more safe, and have a flexible table if you decide to switch things up.