DEV Community

maddrid
maddrid

Posted on

Alternative eloquent model ?

Current version of the eloquent model seems bloated with lots of unnecessary code for just querying the database .

No reusable query builder inside model ,new query class for each db interogation
vast of model code (logic ) moved into controller.
This one doesn't inspire much also : https://github.com/crocodic-studio/laravel-model
display latest posts, most viewed posts, most comented on home page
Each database interogation is a new model, new query builder, each result is a eloquent model.
Each result model has Concerns\HasAttributes,
Concerns\HasEvents,
Concerns\HasGlobalScopes,
Concerns\HasRelationships,
Concerns\HasTimestamps,
Concerns\HidesAttributes,
Concerns\GuardsAttributes,
ForwardsCalls;
to array , means looping on result , just looking for a simple model , not to bring hole script into memory for extract 20 results

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay