id; $library_permission = Model_Library_Permission::find_one_by(function ($query) use ($library_id, $permission_id) { $query ->where('library_id', $library_id) ->and_where('permission_id', $permission_id); }); if ($library_permission === null) { $library_permission = new Model_Library_Permission(); $library_permission->library_id = $library_id; $library_permission->permission_id = $permission_id; } if ($checked === 'false') $library_permission->disable = true; else $library_permission->disable = false; if($parameter !== null) $library_permission->value = $parameter; $library_permission->save(); return $this->response(['error' => false, 'message' => 'Permission modify successfully']); } catch (Exception $exception) { return $this->response(['error' => true, 'message' => $exception->getMessage()]); } } }