Skip to content

Commit

Permalink
Merge branch 'dpankratov/find-findby-methods' into 'master'
Browse files Browse the repository at this point in the history
added find/findBy methods

See merge request components/laravel-helpers!41
  • Loading branch information
Roman Dubrovin committed May 10, 2018
2 parents c4207b1 + 4ab2596 commit 0a9eea2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Traits/EntityControlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ public function firstWithRelations($data, $with = [])
return empty($entity) ? [] : $entity->toArray();
}

public function findBy($field, $value, $relations = [])
{
return $this->firstWithRelations([
$field => $value
], $relations);
}

public function find($id, $relations = [])
{
return $this->firstWithRelations([
'id' => $id
], $relations);
}

public function delete($where)
{
$model = new $this->model;
Expand Down

0 comments on commit 0a9eea2

Please sign in to comment.