facepalm!
I've been relying too much on logging queries. whereIn works. How do I mark this as solved?
The issue with the following code which repeats the 1st value of the array
Event::listen('illuminate.query', function($sql, $bindings, $time)
{
foreach ($bindings as $i => $val) {
$bindings[$i] = "'$val'";
}
$sql = str_replace(['?'], $bindings, $sql);
Log::info($sql . ' elapsed time = ' . $time);
});
Using the following and the correct values were being used
$queries = DB::getQueryLog();
$last = end($queries);
You should use scopes
instead of a static method.
public function scopeSimpleWhereIn_1( $query, $userArray )
{
return $query->whereIn('id', $userArray )
->get( array('id','email', 'first_name', 'last_name') );
}
Then call it like you did earlier:
$simple1 = User::simpleWhereIn_1( $userList );
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community