This content originally appeared on DEV Community and was authored by Ghulam Mujtaba
What is Eloquent?
Eloquent is Laravel's Object-Relational Mapping (ORM) system. It allows you to interact with your database using PHP classes and objects.
Key Features:
- Simplifies database interactions
- Defines database tables as PHP classes (models)
- Supports CRUD operations (Create, Read, Update, Delete)
- Defines relationships between tables
Basic Example:
Let's say we have a jobs
table in your database. With Eloquent, you can create a Job
model to interact with that table:
// app/Models/Job.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Job extends Model
{
protected $table = 'job_listings';
protected $fillable = ['title' , 'salary'];
}
That's it! We can now use the Job
model to perform database operations, like creating a new job.
Eloquent provides a simple and elegant way to work with your database in Laravel.
This content originally appeared on DEV Community and was authored by Ghulam Mujtaba

Ghulam Mujtaba | Sciencx (2024-09-06T17:15:49+00:00) Eloquent in Laravel. Retrieved from https://www.scien.cx/2024/09/06/eloquent-in-laravel/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.