Fix for tests

This commit is contained in:
Hillel Coren 2016-06-07 21:13:29 +03:00
parent 8a9061b00e
commit 4976d5b057
3 changed files with 287 additions and 222 deletions

View File

@ -9,7 +9,7 @@ class EntityRequest extends Request {
protected $entityType; protected $entityType;
private $entity; private $entity;
public function entity() public function entity()
{ {
if ($this->entity) { if ($this->entity) {
return $this->entity; return $this->entity;
@ -20,24 +20,24 @@ class EntityRequest extends Request {
foreach (['_id', 's'] as $suffix) { foreach (['_id', 's'] as $suffix) {
$field = $this->entityType . $suffix; $field = $this->entityType . $suffix;
if ($this->$field) { if ($this->$field) {
$publicId= $this->$field; $publicId= $this->$field;
} }
} }
if ( ! $publicId) { if ( ! $publicId) {
$publicId = Input::get('public_id') ?: Input::get('id'); $publicId = Input::get('public_id') ?: Input::get('id');
} }
if ( ! $publicId) { if ( ! $publicId) {
return null; return null;
} }
$class = Utils::getEntityClass($this->entityType); $class = Utils::getEntityClass($this->entityType);
if (method_exists($class, 'withTrashed')) { if (method_exists($class, 'trashed')) {
$this->entity = $class::scope($publicId)->withTrashed()->firstOrFail(); $this->entity = $class::scope($publicId)->withTrashed()->firstOrFail();
} else { } else {
$this->entity = $class::scope($publicId)->firstOrFail(); $this->entity = $class::scope($publicId)->firstOrFail();
} }
return $this->entity; return $this->entity;
} }

View File

@ -33,7 +33,7 @@ class EntityModel extends Eloquent
$entity->setRelation('user', $user); $entity->setRelation('user', $user);
$entity->setRelation('account', $account); $entity->setRelation('account', $account);
if (method_exists($className, 'withTrashed')){ if (method_exists($className, 'trashed')){
$lastEntity = $className::withTrashed() $lastEntity = $className::withTrashed()
->scope(false, $entity->account_id); ->scope(false, $entity->account_id);
} else { } else {

491
composer.lock generated

File diff suppressed because it is too large Load Diff