Skip to content
Prev Previous commit
Next Next commit
make resource-class detachment semi future-proof in case we have more…
… status codes
  • Loading branch information
aryarm committed Feb 24, 2019
commit 8f289182f7ffc55dcb992491db34b703a23febd1
6 changes: 3 additions & 3 deletions app/Http/Controllers/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ public function detach(Resource $resource, Request $request){
// so we have to check that this operation is truly allowed first
if ($validated['class'])
{
if (Academic_Class::getRoot()->status == 1) {
$resource->class()->dissociate($validated['class'])->save();
if (Academic_Class::getRoot()->status == 0) {
abort(403, "Detaching this resource will attach it to the root, which is currently not allowed.");
}
else
{
abort(403, "Detaching this resource will attach it to the root, which is currently not allowed.");
$resource->class()->dissociate($validated['class'])->save();
}
}
}
Expand Down