#Laravel Naming Conventions

12 messages · Page 1 of 1 (latest)

still basin
#

I am using a repository and service pattern, conventionally, what should I call the destroy method in each class?
Controller => destroy()
Service => destroyPost()
Repository => delete()
Or do you name all the same?

gentle salmon
#

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

vestal hearth
#

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

still basin
vestal hearth
#

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