Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
akiftezcan38 authored and github-actions[bot] committed Feb 28, 2024
1 parent 2bb3600 commit abfe7fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 8 additions & 8 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|null $ignoreScopes = []): ?ConnectiveCollection
public function connectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = []): ?ConnectiveCollection
{
$connections = $this->connections($connectionTypes, $modelTypes);
$collection = ConnectiveCollection::make();
Expand All @@ -86,13 +86,13 @@ 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)){
if ($ignoreScopes && is_array($ignoreScopes)) {
$toModelInstance = $toModelType::withoutGlobalScopes($ignoreScopes)->find($toModelId);
}else{
} else {
$toModelInstance = $toModelType::find($toModelId);
}

if ($toModelInstance != null){
if ($toModelInstance != null) {
$collection->push($toModelInstance);
}

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|null $ignoreScopes = []): ?ConnectiveCollection
public function inverseConnectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = []): ?ConnectiveCollection
{
$incomingConnections = $this->inverseConnections($connectionTypes, $modelTypes);
$collection = ConnectiveCollection::make();
Expand All @@ -139,13 +139,13 @@ public function inverseConnectives(string|array|null $connectionTypes = null, st
$fromModelType = $incomingConnection->from_model_type;
$fromModelId = $incomingConnection->from_model_id;

if ($ignoreScopes && is_array($ignoreScopes)){
if ($ignoreScopes && is_array($ignoreScopes)) {
$fromModelInstance = $fromModelType::withoutGlobalScopes($ignoreScopes)->find($fromModelId);
}else{
} else {
$fromModelInstance = $fromModelType::find($fromModelId);
}

if ($fromModelInstance != null){
if ($fromModelInstance != null) {
$collection->push($fromModelInstance);
}

Expand Down
4 changes: 1 addition & 3 deletions tests/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@
'name' => 'name74',
]);


\AuroraWebSoftware\Connective\Tests\Models\Connective::addGlobalScope('name', function (\Illuminate\Database\Eloquent\Builder $builder) {
$builder->where('name', 'name73');
});
Expand All @@ -392,10 +391,9 @@
$connective2->connectTo($connective4, 'a');

expect($connective2->connectives('a'))->toHaveCount(1);
expect($connective2->connectives('a', null,['name']))->toHaveCount(2);
expect($connective2->connectives('a', null, ['name']))->toHaveCount(2);
});


it('can get inverse connections of a connective model', function () {

/**
Expand Down

0 comments on commit abfe7fb

Please sign in to comment.