Skip to content

Commit

Permalink
Crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarpsvo committed Sep 23, 2020
1 parent 595f31e commit b088d34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Http/Controllers/SortableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ public function updateOrder(NovaRequest $request)
if (empty($resourceClass)) return response()->json(['resourceName' => 'invalid'], 400);

$modelClass = $resourceClass::$model;
$models = $modelClass::withTrashed()->findMany($resourceIds);
if (is_callable($modelClass, 'withTrashed')) {
$models = $modelClass::withTrashed()->findMany($resourceIds);
} else {
$models = $modelClass::findMany($resourceIds);
}
if ($models->count() !== sizeof($resourceIds)) return response()->json(['resourceIds' => 'invalid'], 400);

$model = $models->first();
Expand Down

0 comments on commit b088d34

Please sign in to comment.