Skip to content

Tag: eloquent

Quick Life Hacks with the Eloquent Model

Hi folks, It’s no secret that I love Laravel, and especially love Eloquent. This post isn’t about why various people don’t like Eloquent, etc, etc. but just some “life hacks” of working with Eloquent. #1 – Naming Conventions I personally like to use the following naming convention on my databases (using a forum as an example) forums forums_topics forums_topics_replies Whereas Eloquent would expect the following: forums forum_topics forum_topic_replies I personally dislike this, for no other reason than I like to be able to see what’s being owned by what at a very quick glance. Additionally, namespacing; I like to namespace…

Leave a Comment

How Eloquent breaks the Single Responsibility Principle, and why I’m okay with it

Hi everyone I thought I would discuss a controversial one today, in order to give an articulated response to a common argument about Eloquent (and generally the Active Record pattern) Firstly, just in case you don’t know, here are some definitions: Single Responsibility Principle: The “S” in the “SOLID” principles. In short, this means one class should have one job. The idea is to keep your code modular and easy to switch out. SOLID Principles: I’ll do an article on this one day, but it’s a discussion for another time. Like all principles or methodologies they’re like the Pirate’s Code, they’re more…

1 Comment