Skip to content

Commit

Permalink
WhereIn clause implementation (#65)
Browse files Browse the repository at this point in the history
* Fix model path in the repository generator

* Implement whereIn() clause
  • Loading branch information
Tjoosten authored Nov 26, 2017
1 parent bf0643f commit 7122584
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .php_cs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"7.1.11","version":"2.8.2:v2.8.2#b331701944cbe492e466d2b46b2880068803eb08","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"ensure_fully_multiline":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":[]}
1 change: 1 addition & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function find($id, $columns = ['*'])
public function findBy($field, $value, $columns = ['*'])
public function findAllBy($field, $value, $columns = ['*'])
public function findWhere($where, $columns = ['*'])
public function whereIn($attribute, array $values, $columns = ['*'])
```

**ActivismeBE\DatabaseLayering\Contracts\CriteriaInterface**
Expand Down
2 changes: 1 addition & 1 deletion resources/stubs/repository.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace repository_namespace;

use model_namespace\model_name;
use model_path\model_name;
use ActivismeBE\DatabaseLayering\Repositories\Contracts\RepositoryInterface;
use ActivismeBE\DatabaseLayering\Repositories\Eloquent\Repository;

Expand Down
14 changes: 14 additions & 0 deletions src/ActivismeBE/Repositories/Eloquent/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,20 @@ public function findWhere($where, $columns = ['*'], $or = false)
return $model->get($columns);
}

/**
* Search for matching values in some specific attribute.
*
* @param string $attribute The name from the attribute.
* @param array $values The array of matching values
* @param array$columns The columns u want to display
* @return mixed
*/
public function whereIn($attribute, array $values, $columns = ['*'])
{
$this->applyCriteria();
return $this->model->whereIn($attribute, $values)->get($columns);
}

/**
* Make a model instance in the repository.
*
Expand Down

0 comments on commit 7122584

Please sign in to comment.