-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] BelongsToMany sync does't use configured keys (#2667)
* Merge testSyncBelongsToMany into testBelongsToManySync; * modelKeys replaced with parseIds in sync method; * Add test for handling a collection in sync method;
- Loading branch information
1 parent
0cdba6a
commit 5387d54
Showing
4 changed files
with
108 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MongoDB\Laravel\Tests\Models; | ||
|
||
use MongoDB\Laravel\Eloquent\Model as Eloquent; | ||
|
||
class Experience extends Eloquent | ||
{ | ||
protected $connection = 'mongodb'; | ||
protected $collection = 'experiences'; | ||
protected static $unguarded = true; | ||
|
||
protected $casts = ['years' => 'int']; | ||
|
||
public function skillsWithCustomRelatedKey() | ||
{ | ||
return $this->belongsToMany(Skill::class, relatedKey: 'cskill_id'); | ||
} | ||
|
||
public function skillsWithCustomParentKey() | ||
{ | ||
return $this->belongsToMany(Skill::class, parentKey: 'cexperience_id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MongoDB\Laravel\Tests\Models; | ||
|
||
use MongoDB\Laravel\Eloquent\Model as Eloquent; | ||
|
||
class Skill extends Eloquent | ||
{ | ||
protected $connection = 'mongodb'; | ||
protected $collection = 'skills'; | ||
protected static $unguarded = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters