Laravel

What is Eloquent in Laravel?

Kartic1 min read

Eloquent is the ORM used to interact with the database using Model classes. It gives handy methods on class objects to make a query on the database.

It can directly be used to retrieve data from any table and run any raw query. But in conjunction with Models, we can make use of its various methods and also make use of relationships and attributes defined on the model.

Some examples of using the Eloquent are below:

  • `DB::table(‘users’)->get()`
  • `User::all()`
  • `User::where(‘name’, ‘=’, ‘Eloquent’)->get()`
Share this articleLinkedIn X

Discussion (0)

Sign in to join the discussion.

Delete this comment?

This will also remove its replies.

Keep exploring

Laravel2 min read

What are accessors and mutators in laravel?

Accessors are a way to retrieve data from eloquent after doing some operation on the retrieved fields from the database. For example, if we need to combine the first and last names...

Kartic · Dec 22, 2022
Laravel1 min read

Explain Closures in laravel?

In Laravel, a closure is an anonymous function that often used as callback methods. Developers can also use it as a parameter in a function. Example: In Laravel, a closure is an an...

Kartic · Oct 24, 2019
Laravel1 min read

Session and Cookies in laravel

Session1. Retrieving Data from sessionsession()->get('key');2. Retrieving All session datasession()->all();3. Remove data from sessionsession()->forget('key'); or session()->flush(...

Kartic · Oct 24, 2019

Follow the engineering notes.

Subscribe for technical articles from iTechOrbit.