Skip to content

Commit

Permalink
AbstractRepository所有查询改为使用Query::table
Browse files Browse the repository at this point in the history
  • Loading branch information
jqhph committed Feb 20, 2019
1 parent f7346d4 commit 744ff08
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/Repository/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ public function find(Model $model)
*/
public function findForView(Show $show)
{
$entity = $this->entityClass;

$query = $entity::findById($show->getId())->getResult();

return $query ? $query->toArray() : [];
return Query::table($this->entityClass)
->where($this->getKeyName(), $show->getId())
->one()
->getResult();
}

/**
Expand All @@ -85,11 +84,10 @@ public function findForView(Show $show)
*/
public function findForEdit(Form $form)
{
$entity = $this->entityClass;

$query = $entity::findById($form->getId())->getResult();

return $query ? $query->toArray() : [];
return Query::table($this->entityClass)
->where($this->getKeyName(), $form->getId())
->one()
->getResult();
}

/**
Expand Down Expand Up @@ -149,10 +147,9 @@ public function delete(Form $form)
*/
public function findForDeleteFiles($id)
{
$entity = $this->entityClass;

$result = $entity::findById($id)->getResult();

return $result ? $result->toArray() : [];
return Query::table($this->entityClass)
->where($this->getKeyName(), $id)
->one()
->getResult();
}
}

0 comments on commit 744ff08

Please sign in to comment.