Skip to content

Commit

Permalink
Store deleted scoped.
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Oct 1, 2020
1 parent 228603b commit 7eefb8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Eloquent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static function serialize(EloquentBuilder $builder): array
'eager' => \collect($builder->getEagerLoads())->map(function ($callback) {
return \serialize(new SerializableClosure($callback));
})->all(),
'deletedScoped' => $builder->removedScopes(),
],
'builder' => Query::serialize($builder->getQuery()),
];
Expand All @@ -33,12 +34,11 @@ public static function unserialize(array $payload): EloquentBuilder
$model->setConnection($payload['model']['connection']);
});


return (new EloquentBuilder(Query::unserialize($payload['builder'])))
->setModel($model)
->setEagerLoads(
collect($payload['model']['eager'])->map(function ($callback) {
return unserialize($callback);
\collect($payload['model']['eager'])->map(function ($callback) {
return \unserialize($callback);
})->all()
);
}
Expand Down
1 change: 0 additions & 1 deletion src/JoinClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public static function unserialize(QueryBuilder $builder, array $joins): array
$results[] = $joinClauseBuilder;
}


return $results;
}
}
5 changes: 5 additions & 0 deletions tests/Feature/EloquentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function it_can_serialize_a_basic_eloquent_builder()
'class' => User::class,
'connection' => null,
'eager' => [],
'deletedScoped' => [],
],
'builder' => [
'connection' => 'testing',
Expand Down Expand Up @@ -48,6 +49,7 @@ public function it_can_serialize_a_basic_eloquent_builder_on_custom_connection()
'class' => User::class,
'connection' => 'mysql',
'eager' => [],
'deletedScoped' => [],
],
'builder' => [
'connection' => 'mysql',
Expand Down Expand Up @@ -77,6 +79,7 @@ public function it_can_serialize_a_basic_eloquent_builder_with_wheres()
'class' => User::class,
'connection' => null,
'eager' => [],
'deletedScoped' => [],
],
'builder' => [
'connection' => 'testing',
Expand Down Expand Up @@ -111,6 +114,7 @@ public function it_can_serialize_a_basic_eloquent_builder_with_join()
'class' => Post::class,
'connection' => null,
'eager' => [],
'deletedScoped' => [],
],
'builder' => [
'connection' => 'testing',
Expand Down Expand Up @@ -158,6 +162,7 @@ public function it_can_serialize_a_basic_eloquent_builder_with_belongs_to_many_j
'class' => User::class,
'connection' => null,
'eager' => [],
'deletedScoped' => [],
],
'builder' => [
'connection' => 'testing',
Expand Down

0 comments on commit 7eefb8f

Please sign in to comment.