DEV Community

Justin Ho
Justin Ho

Posted on • Edited on

Drawbacks of Laravel's ORM - Eloquent

Day 2 of #100DaysOfCode

  1. Finished writing migrations for HypeTracker's database in Laravel.

  2. Working on adding the mutators for each Model class because I decided to give Laravel's ORM, Eloquent, a shot.

Learnings

Found out that even though composite (primary) keys are available in migrations, it's not an available option for Eloquent ORM Model classes?

Very interesting block and decided to look into it.

Found this thread on stackoverflow explaining its non-supported use and a workaround (it's been asked about for over 5 years!).

Of course, because it's an open source project, I wanted to take a look on the repository to see if this has been implemented since that time.

Relevant GitHub issue 1 and 2

Basically nothing has been done yet.

But that's just the nature of open source projects, the bigger the project, the slower things are going to move. Especially when they see this as a non-issue.

Of course, I'm not going to just give up and scrap all my current work. I just used the workaround for now and see how it goes.

Moral of the story?

ORMs can help in abstracting database queries and makes your program "database-agnostic", but you are depending on the upstream or basically "vendor-locked" if any issues arise.

Afterwords

Let me know if you use an ORM or raw SQL in the commets!

Follow my journey on DEV or twitter!

Read why I'm refactoring a 2 year old project

HypeTracker Repository

GitHub logo jcsho / hype-tracker

Full stack web application to read data from public APIs (Twitter, Reddit) and form visualizations

HypeTracker

Current Version Codacy Badge StyleCI License FOSSA Status


HypeTracker is a data aggregator application for social media 'impressions' on sneakers bought and sold in the aftermarket.

See my blog detailing what HypeTracker is and why I am refactoring it

Changelog / Goals for V2

  • migrate database schema see PR #4
  • migrate internal sneakers API see PR #7
  • migrate front-end see PR #17
  • deploy as demo / push as v2
  • add social media api scraping

Getting Started

Requirements

Homestead

  • PHP ^7.3
  • Composer ^1.10.13
  • Vagrant ^2.2.10 (with your choice of virtualization layer)
  • (example) VirtualBox ^6.1.14 (with Vagrant's VirtualBox provider)
$ git clone https://github.com/justinhodev/hype-tracker.git
$ cd hype-tracker

# Install Composer Dependencies
$ composer install

# Prepare config for Homestead
$ composer homestead

# Provision the VM
$ vagrant up

# SSH into Vagrant Box
$ vagrant ssh
Enter fullscreen mode Exit fullscreen mode

Docker

coming soon

Database Entity Relationship Model

ER Diagram

License

FOSSA Status




Top comments (0)