Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/reverse-connections' into revers…
Browse files Browse the repository at this point in the history
…e-connections
  • Loading branch information
emreakay committed Feb 23, 2024
2 parents 21d8e9e + cd8dbbe commit 226064b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Collections/ConnectiveCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ConnectiveCollection extends Collection
/**
* @return ?ConnectiveCollection<ConnectiveContract>
*/
public function connectives(string|array $connectionTypes = null, string|array $modelTypes = null): ?ConnectiveCollection
public function connectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null): ?ConnectiveCollection
{
/**
* @var ConnectiveCollection<ConnectiveContract> $collection;
Expand Down
4 changes: 2 additions & 2 deletions src/Contracts/ConnectiveContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function connectTo(ConnectiveContract&Model $model, string $connectionTyp
* @param string|array<class-string> $modelTypes
* @return Collection<Connection>|null
*/
public function connections(string|array $connectionTypes = null, string|array $modelTypes = null): ?Collection;
public function connections(string|array|null $connectionTypes = null, string|array|null $modelTypes = null): ?Collection;

/**
* returns connected model instances (connective models) as a collection
Expand All @@ -48,7 +48,7 @@ public function connectives(string|array $connectionTypes, string|array $modelTy
* @param string|array<class-string> $modelTypes
* @return Collection<Connection>|null
*/
public function inverseConnections(string|array $connectionTypes = null, string|array $modelTypes = null): ?Collection;
public function inverseConnections(string|array|null $connectionTypes = null, string|array|null $modelTypes = null): ?Collection;

/**
* returns connected model instances (connective models) as a collection
Expand Down
8 changes: 4 additions & 4 deletions src/Models/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use Illuminate\Database\Eloquent\Model;

/**
* @property class-string $to_model_type
* @property int $to_model_id
* @property class-string $from_model_type
* @property int $from_model_id
* @property class-string $to_model_type
* @property int $to_model_id
* @property class-string $from_model_type
* @property int $from_model_id
*/
class Connection extends Model
{
Expand Down
8 changes: 4 additions & 4 deletions src/Traits/Connective.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function connectTo(ConnectiveContract&Model $model, string $connectionTyp
* @param string|array<class-string> $modelTypes
* @return Collection<Connection>|null
*/
public function connections(string|array $connectionTypes = null, string|array $modelTypes = null): ?Collection
public function connections(string|array|null $connectionTypes = null, string|array|null $modelTypes = null): ?Collection
{
$query = Connection::query();

Expand All @@ -77,7 +77,7 @@ public function connections(string|array $connectionTypes = null, string|array $
/**
* @return ConnectiveCollection<ConnectiveContract>|null
*/
public function connectives(string|array $connectionTypes = null, string|array $modelTypes = null): ?ConnectiveCollection
public function connectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null): ?ConnectiveCollection
{
$connections = $this->connections($connectionTypes, $modelTypes);
$collection = ConnectiveCollection::make();
Expand All @@ -99,7 +99,7 @@ public function connectives(string|array $connectionTypes = null, string|array $
* @param string|array<class-string> $modelTypes
* @return Collection<Connection>|null
*/
public function inverseConnections(string|array $connectionTypes = null, string|array $modelTypes = null): ?Collection
public function inverseConnections(string|array|null $connectionTypes = null, string|array|null $modelTypes = null): ?Collection
{
$query = Connection::query();

Expand All @@ -122,7 +122,7 @@ public function inverseConnections(string|array $connectionTypes = null, string|
/**
* @return ConnectiveCollection<ConnectiveContract>|null
*/
public function inverseConnectives(string|array $connectionTypes = null, string|array $modelTypes = null): ?ConnectiveCollection
public function inverseConnectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null): ?ConnectiveCollection
{
$incomingConnections = $this->inverseConnections($connectionTypes, $modelTypes);
$collection = ConnectiveCollection::make();
Expand Down
1 change: 0 additions & 1 deletion tests/Models/OtherConnective.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use AuroraWebSoftware\Connective\Contracts\ConnectiveContract;
use Illuminate\Database\Eloquent\Model;


/**
* @property string $name
*/
Expand Down
3 changes: 0 additions & 3 deletions tests/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@
->toHaveCount(1)
->each->toBeInstanceOf(ConnectiveContract::class);


expect($connective3->inverseConnectives(connectionTypes: 'a'))
->toHaveCount(1)
->each->toBeInstanceOf(ConnectiveContract::class);
Expand All @@ -496,6 +495,4 @@
->toHaveCount(1);
});



// connected to ve coonetedfrom testleri

0 comments on commit 226064b

Please sign in to comment.