Eloquent in Laravel

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 a…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Eloquent in Laravel." Ghulam Mujtaba | Sciencx - Friday September 6, 2024, https://www.scien.cx/2024/09/06/eloquent-in-laravel/
HARVARD
Ghulam Mujtaba | Sciencx Friday September 6, 2024 » Eloquent in Laravel., viewed ,<https://www.scien.cx/2024/09/06/eloquent-in-laravel/>
VANCOUVER
Ghulam Mujtaba | Sciencx - » Eloquent in Laravel. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/06/eloquent-in-laravel/
CHICAGO
" » Eloquent in Laravel." Ghulam Mujtaba | Sciencx - Accessed . https://www.scien.cx/2024/09/06/eloquent-in-laravel/
IEEE
" » Eloquent in Laravel." Ghulam Mujtaba | Sciencx [Online]. Available: https://www.scien.cx/2024/09/06/eloquent-in-laravel/. [Accessed: ]
rf:citation
» Eloquent in Laravel | Ghulam Mujtaba | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.