Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Update ManyToManyRelation.php
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j authored Nov 16, 2018
1 parent bebc77c commit 59fb4c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ public function link(RecordInterface $record, array $pivotData = []): self
//Ensure reference
$record = $this->matchOne($record) ?? $record;

if (in_array($record, $this->instances)) {
if (in_array($record, $this->instances, true)) {
//Merging pivot data
$this->pivotData->offsetSet($record, $pivotData + $this->getPivot($record));

if (!in_array($record, $this->updated) && !in_array($record, $this->scheduled)) {
if (!in_array($record, $this->updated, true) && !in_array($record, $this->scheduled, true)) {
//Indicating that record pivot data has been changed
$this->updated[] = $record;
}
Expand Down Expand Up @@ -267,13 +267,13 @@ public function queueCommands(ContextualCommandInterface $parentCommand): Comman
$transaction->addCommand($recordCommand = $record->queueStore(), true);

//Create or refresh link between records
if (in_array($record, $this->scheduled)) {
if (in_array($record, $this->scheduled, true)) {
//Create link
$command = new InsertCommand(
$this->pivotTable(),
$this->pivotData->offsetGet($record)
);
} elseif (in_array($record, $this->updated)) {
} elseif (in_array($record, $this->updated, true)) {
//Update link (expecting both records to be already loaded)
$command = new UpdateCommand(
$this->pivotTable(),
Expand Down

0 comments on commit 59fb4c2

Please sign in to comment.