Multiple Where Condition in Laravel Eloquent

 First we will see that, what is eloquent in laravel. Then we will see the example for Where condition.

What is Laravel Eloquent?

Eloquent is an ORM (Object Relation Mapper) and it helps to interact with the database and get the records from the database table according to your query. 

Eloquent has the ability to insert new records, delete, update records with the built-in very easy functions.

Where Condition in Laravel Eloquent

Eloquent where condition use to get data from database based the specific conditions. We already knew about SQL query with where condition and it is very long.

So eloquent provide you short, fast, easily retrieves data from the database table. We can also add multiple where condition and use them in the query builder.

Eloquent Query Syntax

public function index() {
    $projects = Project::where(“status”, “=”, 1)->get();

    dd($projects);
}

Multiple Where Condition in Laravel Eloquent

Example:
public function index() {
    $projects = Project::where([‘status’ => ‘1’, ‘not_completed’ => ‘0’, ‘user_id’ => ‘24’])->get();

    dd($projects);
}

Check here more examples.

 

 

 

Comments

Popular posts from this blog

What is the Difference Between Git fetch and Git pull?

WooCommerce Redirect to Checkout After Click on Add to Cart