I'm trying to create a custom "lists" method in my repository so I can pass an array of conditions but it's not working.
public function lists( array $conditions, $value, $key, $distinct = false )
{
$query = $this->model();
foreach( $conditions as $keyvalue => $columnvalue )
{
if( $keyvalue == 'id' )
{
$query->where($keyvalue, '=', $columnvalue );
}
else
{
$query->where($keyvalue, 'LIKE', '%'.$columnvalue.'%'); // Non-empty string for example; posted a story id
}
}
if( $distinct )
{
return $query->distinct()->lists( $value, $key );
}
else
{
return $query->lists( $value, $key );
}
}
Any help appreciated, it returns all values and ignores the where clause.