#Laravel Naming Conventions
12 messages · Page 1 of 1 (latest)
Naming things would usually be done with the same concepts. Like you have a PostService class, then having a method destroyPost doesn't make much sense, as the method is already defined in a class that describes what it's about
I really dislike using the same function names everywhere due to searchability/replaceability so I use
Controller => destroy()
Service => makePerish()
Repository => obliterate()
/s
We do destroy (controller) -> destroy (service) -> delete (repository)
Still not a fan of using destroy twice, but alas
what's stopping us from using these names
Nothing much really. I think using naming conventions in controllers is probably useful because of certain scaffolding using these names as well
Basically this in the docs: https://laravel.com/docs/10.x/controllers#actions-handled-by-resource-controller
Not sure if there is auto-discovery as well, so I'd definitely use these names for your controller functions
Service and repository? Nothing official on naming, I believe
Personally for repositories I like using the sql syntax as function name
Delete, insert, update etc