Skip to content

Commit

Permalink
Merge pull request #5 from thiagoprz/dev
Browse files Browse the repository at this point in the history
Fix for trashed queries
  • Loading branch information
thiagoprz committed Sep 8, 2022
2 parents 587b3dc + 23af74b commit 3a75e97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Models/ModelCrud.php
Expand Up @@ -104,8 +104,8 @@ public static function search(array $data)
* @see ModelCrud::$withTrashedForbidden
*/
if (in_array(SoftDeletes::class, class_uses(self::class), true)) {
self::applyOnlyTrashed($query);
self::applyWithTrashed($query);
self::applyOnlyTrashed($query, $data);
self::applyWithTrashed($query, $data);
}

$result = !empty($data['no_pagination']) && !isset(self::$noPaginationForbidden) ? $query->get() : self::setSearchPagination($query);
Expand Down Expand Up @@ -185,7 +185,7 @@ public static function setSearchPagination($query)
*/
public static function applyWithTrashed($query, array $data)
{
if (!self::$withTrashedForbidden && $data['with_trashed']) {
if (!self::$withTrashedForbidden && !empty($data['with_trashed'])) {
$query->withTrashed();
}
}
Expand All @@ -198,7 +198,7 @@ public static function applyWithTrashed($query, array $data)
*/
public static function applyOnlyTrashed($query, array $data)
{
if (!self::$onlyTrashedForbidden && $data['only_trashed']) {
if (!self::$onlyTrashedForbidden && !empty($data['only_trashed'])) {
$query->onlyTrashed();
}
}
Expand Down

0 comments on commit 3a75e97

Please sign in to comment.