M
M
Maxim Zolotoy2020-01-20 11:05:45
ORM
Maxim Zolotoy, 2020-01-20 11:05:45

Is it necessary to use Eloquent ORM in Laravel?

I don’t have much experience with Laravel and I wanted to ask - is it necessary to use Eloquent ORM models at all or can I just write my own and use the DB facade to work with the database?
It’s just that these models are of course convenient, but they don’t cover most of my data retrieval needs, since I often need to sort the data in a certain way when retrieving, and it turns out some sort of mess - in one place I use ORM in another, I just make queries to the database, and so on.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Romashkan, 2020-01-20
@EvgeniiR

Is it necessary to use Eloquent ORM in Laravel?

No, not necessarily.
Make raw queries to the database. No need to pull an owl on the selection globe on the ORM.
ORM helps when you need models with logic for some operation. If the goal is just to get data from the database - SQL selections and DTO mapping are still the best choice.

N
NikSIk31, 2020-01-20
@NikSIk31

You are offered a handy tool that covers a huge number of database tasks. But, they also gave the opportunity to write their own requests, so what's the problem with using it mixed?
For example, if some narrow task cannot be solved with a standard set of Laravel functions for working with a database, then why not use some handwritten version?
Laravel is a very flexible tool

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question