To answer the question in your comment, there is nothing to extend. The default is already 'and'. For example, lets take a look at what you wrote:
select from "table" where "name" is equal to "jason" AND where "age" is equal to "16"
The default where
clause already does what you want.
Model::where('name', '=', 'jason')
->where('age', '=', 16)
->get();
This turns into something along the lines of select * from `TABLE` where `name` = jason and `age` = 16
.
If you take a look at the where
method in either the eloquent/query builder, you will see this:
public function where($column, $operator = null, $value = null, $boolean = 'and')
As you can see from the 4th parameter, the default is already 'and'. On a related note, you can override that and put 'or', if you want.
Model::where('name', '=', 'jason')
->where('age', '=', 16, 'or')
->get();
There is also a orWhere
method that does that for you though.
Model::where('name', '=', 'jason')
->orWhere('age', '=', 16)
->get();
This will turn into something like this:
select * from `TABLE` where `name` = jason or `age` = 16
.
Edit: Just noticed that you edited your question.
"table" where "student_staff" is equal to "student" 'AND' where "department" is equal to "all" or "department" is equal to "department1
I think what you want is actually this: "student_staff" is equal to "student" 'AND' (where "department" is equal to "all" or "department" is equal to "department1)
This is called parameter grouping. Docs on that here: http://laravel.com/docs/5.1/queries#advanced-where-clauses
To achieve this statement, it would be something like this:
$models = Model::where('student_staff', '=', 'student')
->where(function($query) {
$query->where('department', '=', 'all')
->orWhere('department', '=', 'department1');
})->get();