commit
774857a93c
|
@ -186,7 +186,7 @@ class DatabaseAdapter implements DatabaseAdapterContract, BatchDatabaseAdapterCo
|
||||||
*/
|
*/
|
||||||
public function removePolicies(string $sec, string $ptype, array $rules): void
|
public function removePolicies(string $sec, string $ptype, array $rules): void
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($sec, $rules, $ptype) {
|
$this->eloquent->getConnection()->transaction(function () use ($sec, $rules, $ptype) {
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
$this->removePolicy($sec, $ptype, $rule);
|
$this->removePolicy($sec, $ptype, $rule);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,11 @@ class DatabaseAdapter implements DatabaseAdapterContract, BatchDatabaseAdapterCo
|
||||||
foreach($oldRule as $k => $v) {
|
foreach($oldRule as $k => $v) {
|
||||||
$instance->where('v' . $k, $v);
|
$instance->where('v' . $k, $v);
|
||||||
}
|
}
|
||||||
$instance->first();
|
$instance = $instance->first();
|
||||||
|
if (!$instance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$update = [];
|
$update = [];
|
||||||
foreach($newPolicy as $k => $v) {
|
foreach($newPolicy as $k => $v) {
|
||||||
$update['v' . $k] = $v;
|
$update['v' . $k] = $v;
|
||||||
|
@ -276,7 +280,7 @@ class DatabaseAdapter implements DatabaseAdapterContract, BatchDatabaseAdapterCo
|
||||||
*/
|
*/
|
||||||
public function updatePolicies(string $sec, string $ptype, array $oldRules, array $newRules): void
|
public function updatePolicies(string $sec, string $ptype, array $oldRules, array $newRules): void
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($sec, $ptype, $oldRules, $newRules) {
|
$this->eloquent->getConnection()->transaction(function () use ($sec, $ptype, $oldRules, $newRules) {
|
||||||
foreach ($oldRules as $i => $oldRule) {
|
foreach ($oldRules as $i => $oldRule) {
|
||||||
$this->updatePolicy($sec, $ptype, $oldRule, $newRules[$i]);
|
$this->updatePolicy($sec, $ptype, $oldRule, $newRules[$i]);
|
||||||
}
|
}
|
||||||
|
@ -296,7 +300,7 @@ class DatabaseAdapter implements DatabaseAdapterContract, BatchDatabaseAdapterCo
|
||||||
public function updateFilteredPolicies(string $sec, string $ptype, array $newPolicies, int $fieldIndex, string ...$fieldValues): array
|
public function updateFilteredPolicies(string $sec, string $ptype, array $newPolicies, int $fieldIndex, string ...$fieldValues): array
|
||||||
{
|
{
|
||||||
$oldRules = [];
|
$oldRules = [];
|
||||||
DB::transaction(function () use ($sec, $ptype, $fieldIndex, $fieldValues, $newPolicies, &$oldRules) {
|
$this->eloquent->getConnection()->transaction(function () use ($sec, $ptype, $fieldIndex, $fieldValues, $newPolicies, &$oldRules) {
|
||||||
$oldRules = $this->_removeFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues);
|
$oldRules = $this->_removeFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues);
|
||||||
$this->addPolicies($sec, $ptype, $newPolicies);
|
$this->addPolicies($sec, $ptype, $newPolicies);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue