Combining AND/OR eloquent query in Laravel

laravel, php

Solution

You can nest where clauses : http://laravel.com/docs/database/fluent#nested-where

Model::where(function($query)
{
    $query->where('a', 'like', 'keyword');
    $query->or_where('b', 'like', 'keyword');
})
->where('c', '=', '1');

This should produce : `SELECT * FROM models WHERE (a LIKE %keyword% OR b LIKE %keyword%) AND c = 1`

Problem

How can I write following or similar kind of queries using Eloquent? `SELECT * FROM a_table WHERE (a LIKE %keyword% OR b LIKE %keyword%) AND c = 1 AND d = 5` I couldn't combine AND/OR in the way I wanted by chaining where & or_where functions.

Original source