Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Try catch on toggle active update value
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordi Puigdellívol committed Nov 19, 2024
1 parent 6224647 commit 891043e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Controllers/ThrustActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ public function toggle($resourceName, $id, $field)
{
$resource = Thrust::make($resourceName);
$object = $resource->find($id);
if(! method_exists($object, 'toggleActive')){
$object->update([$field => !$object->{$field}]);
return back();
}
try {
if(! method_exists($object, 'toggleActive')){
$object->update([$field => !$object->{$field}]);
return back();
}

$object->toggleActive();
return back();
}catch(\Exception $e){
Expand Down

0 comments on commit 891043e

Please sign in to comment.