File tree 2 files changed +9
-9
lines changed
2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ public function up(): void
10
10
{
11
11
Schema::create ('team_user ' , function (Blueprint $ table ): void {
12
12
$ table ->id ();
13
- $ table ->foreignId ('team_id ' )->constrained ();
14
- $ table ->foreignId ('user_id ' )->constrained ();
15
- $ table ->string ('role ' )->nullable ();
13
+ $ table ->foreignId ('team_id ' )->constrained ();
14
+ $ table ->foreignId ('user_id ' )->constrained ();
15
+ $ table ->string ('role ' )->nullable ();
16
16
$ table ->timestamps ();
17
17
});
18
18
}
Original file line number Diff line number Diff line change 8
8
9
9
uses (TestCase::class);
10
10
11
- it ('can prepare query for no constraints ' , function () {
11
+ it ('can prepare query for no constraints for a BelongsToMany relationship ' , function () {
12
12
$ user = User::factory ()->create ();
13
13
14
14
expect ($ user ->teams ()->toBase ())
72
72
]);
73
73
74
74
$ query = app (RelationshipJoiner::class)->prepareQueryForNoConstraints (
75
- $ user ->teams ()->orderBy (new Expression ("CASE WHEN role = 'some_other_role' THEN 1 ELSE 2 END " ))
75
+ $ user ->teams ()->orderBy (new Expression ("CASE WHEN role = 'some_other_role' THEN 1 ELSE 2 END " ))
76
76
);
77
77
78
78
expect ($ query ->toBase ())
81
81
(new Team )->qualifyColumn ('* ' ),
82
82
"CASE WHEN role = 'user' THEN 1 ELSE 2 END " , // Select added from `orderByRaw`...
83
83
])
84
- ->orders ->toHaveCount (1 )
85
- ->and ($ query ->toBase ()->orders [0 ])
86
- ->column ->getValue ($ user ->teams ()->getGrammar ())->toBe ("CASE WHEN role = 'some_other_role' THEN 1 ELSE 2 END " )
87
- ->direction ->toBe ('asc ' );
84
+ ->orders ->toHaveCount (1 )
85
+ ->and ($ query ->toBase ()->orders [0 ])
86
+ ->column ->getValue ($ user ->teams ()->getGrammar ())->toBe ("CASE WHEN role = 'some_other_role' THEN 1 ELSE 2 END " )
87
+ ->direction ->toBe ('asc ' );
88
88
});
You can’t perform that action at this time.
0 commit comments