-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Labels
Description
I needed more than one condition in getAllBy method and I made changes like this:
public function getAllBy(array $conditions = array(), array $with = array('translations'), $all = false)
{
$query = $this->make($with);
if (! $all) {
// Take only online and translated items
$query = $query->whereHasOnlineTranslation();
}
if(is_array($conditions) && count($conditions))
{
foreach($conditions as $key => $value)
{
$query->where($key, $value);
}
}
$models = $query->get();
return $models;
}And then in any Controller:
$conditions = array(
'category_id' => $category->id,
'type' => $type
);
$data = $this->repository->getAllBy($conditions, $relatedModels, false);What do you think about this?