Skip to content

Commit

Permalink
#added-ignore-scopes-in-connectives-func updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehmet Akif TEZCAN committed Feb 28, 2024
1 parent abfe7fb commit 343553e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Traits/Connective.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function connections(string|array|null $connectionTypes = null, string|ar
/**
* @return ConnectiveCollection<ConnectiveContract>|null
*/
public function connectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = []): ?ConnectiveCollection
public function connectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = null): ?ConnectiveCollection
{
$connections = $this->connections($connectionTypes, $modelTypes);
$collection = ConnectiveCollection::make();
Expand All @@ -86,8 +86,8 @@ public function connectives(string|array|null $connectionTypes = null, string|ar
$toModelType = $connection->to_model_type;
$toModelId = $connection->to_model_id;

if ($ignoreScopes && is_array($ignoreScopes)) {
$toModelInstance = $toModelType::withoutGlobalScopes($ignoreScopes)->find($toModelId);
if (is_array($ignoreScopes)) {
$toModelInstance = $toModelType::withoutGlobalScopes($ignoreScopes == [] ? null : $ignoreScopes)->find($toModelId);
} else {
$toModelInstance = $toModelType::find($toModelId);
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public function inverseConnections(string|array|null $connectionTypes = null, st
/**
* @return ConnectiveCollection<ConnectiveContract>|null
*/
public function inverseConnectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = []): ?ConnectiveCollection
public function inverseConnectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = null): ?ConnectiveCollection
{
$incomingConnections = $this->inverseConnections($connectionTypes, $modelTypes);
$collection = ConnectiveCollection::make();
Expand All @@ -139,8 +139,8 @@ public function inverseConnectives(string|array|null $connectionTypes = null, st
$fromModelType = $incomingConnection->from_model_type;
$fromModelId = $incomingConnection->from_model_id;

if ($ignoreScopes && is_array($ignoreScopes)) {
$fromModelInstance = $fromModelType::withoutGlobalScopes($ignoreScopes)->find($fromModelId);
if (is_array($ignoreScopes)) {
$fromModelInstance = $fromModelType::withoutGlobalScopes($ignoreScopes == [] ? null : $ignoreScopes)->find($fromModelId);
} else {
$fromModelInstance = $fromModelType::find($fromModelId);
}
Expand Down

0 comments on commit 343553e

Please sign in to comment.