Skip to content

Commit

Permalink
Get pk from the model if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Gwerder committed Mar 13, 2017
1 parent 08d31f4 commit b129178
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,18 @@ public function parse($options, $multiple = false)
} else {
$identification = $options;

if (is_numeric($identification)) {
$this->query->where('id', $identification);
} else if (is_array($identification)) {
if (is_array($identification)) {
foreach ($identification as $column => $value) {
$this->query->where($column, $value);
}
} else {
if($this->isEloquentBuilder) {
$primaryKey = $this->builder->getModel()->getQualifiedKeyName();
} else {
$primaryKey = $this->getQualifiedColumnName('id');
}

$this->query->where($primaryKey, $identification);
}
}

Expand Down

0 comments on commit b129178

Please sign in to comment.