File tree Expand file tree Collapse file tree 4 files changed +47
-7
lines changed Expand file tree Collapse file tree 4 files changed +47
-7
lines changed Original file line number Diff line number Diff line change 44
55use AuroraWebSoftware \Connective \Collections \ConnectiveCollection ;
66use AuroraWebSoftware \Connective \Contracts \ConnectiveContract ;
7+ use Illuminate \Database \Eloquent \Collection ;
8+ use Illuminate \Database \Eloquent \Model ;
79
810/**
911 * issue actor can be one of the following:
@@ -26,4 +28,9 @@ public function getActingIssues(string $connectionType): ConnectiveCollection;
2628 * ['channel' => 'email', 'email' => '[email protected] '] 2729 */
2830 public function getIssueReminderConfig (): array ;
31+
32+ /**
33+ * @return Collection<int, Model&IssueActorModelContract>
34+ */
35+ public static function searchIssueActor (string $ searchTerm ): Collection ;
2936}
Original file line number Diff line number Diff line change 1515use AuroraWebSoftware \Connective \Contracts \ConnectiveContract ;
1616use AuroraWebSoftware \Connective \Exceptions \ConnectionTypeException ;
1717use AuroraWebSoftware \Connective \Exceptions \ConnectionTypeNotSupportedException ;
18+ use AuroraWebSoftware \Connective \Models \Connection ;
1819use AuroraWebSoftware \Connective \Traits \Connective ;
1920use Illuminate \Database \Eloquent \Model ;
2021use Illuminate \Support \Carbon ;
@@ -167,18 +168,25 @@ public function addObserver(IssueActorModelContract&Model $issueActorModel): voi
167168
168169 public function removeObserver (IssueActorModelContract $ issueActorModel ): void
169170 {
170- foreach ($ this ->getObservers () ?? [] as $ observer ) {
171- if ($ observer ->getId () === $ issueActorModel ->getId ()) {
172- $ observer ->delete ();
173- break ;
174- }
171+ if ($ this ->connections ('issue_observer ' )) {
172+ $ this ->connections ('issue_observer ' )
173+ ->each (function (Model $ connection ) use ($ issueActorModel ) {
174+
175+ /**
176+ * @var Connection $connection
177+ */
178+ if ($ connection ->connectedTo ()->getId () === $ issueActorModel ->getId ()) {
179+ $ connection ->delete ();
180+ }
181+ });
175182 }
176183 }
177184
178185 public function removeAllObservers (): void
179186 {
180- foreach ($ this ->getObservers () ?? [] as $ observer ) {
181- $ observer ->delete ();
187+ if ($ this ->connections ('issue_observer ' )) {
188+ $ this ->connections ('issue_observer ' )
189+ ->each (fn (Model $ connection ) => $ connection ->delete ());
182190 }
183191 }
184192
Original file line number Diff line number Diff line change 66use AuroraWebSoftware \AIssue \Traits \AIssueActor ;
77use AuroraWebSoftware \Connective \Contracts \ConnectiveContract ;
88use AuroraWebSoftware \Connective \Traits \Connective ;
9+ use Illuminate \Database \Eloquent \Collection ;
910use Illuminate \Database \Eloquent \Model ;
1011
1112/**
@@ -32,4 +33,14 @@ public function getIssueReminderConfig(): array
3233 {
3334 return [
'channel ' =>
'email ' ,
'email ' =>
'[email protected] ' ];
3435 }
36+
37+ /**
38+ * @return Collection<IssueActorModelContract>
39+ *
40+ * @phpstan-ignore-next-line
41+ */
42+ public static function searchIssueActor (string $ searchTerm ): Collection
43+ {
44+ return User::query ()->where ('name ' , 'like ' , '% ' .$ searchTerm .'% ' )->get ();
45+ }
3546}
Original file line number Diff line number Diff line change 203203 $ exampleIssueOwner1 ->ownIssue ($ issue );
204204 expect ($ exampleIssueOwner1 ->getOwningIssues ())->toHaveCount (1 );
205205
206+ // dd(User::searchIssueActor('user'));
207+
208+ // search actor
209+ expect (User::searchIssueActor ('user ' ))
210+ ->toHaveCount (4 )
211+ ->and (User::searchIssueActor ('user 1 ' ))
212+ ->toHaveCount (1 )
213+ ->and (User::searchIssueActor ('user 2 ' ))
214+ ->toHaveCount (1 )
215+ ->and (User::searchIssueActor ('user 3 ' ))
216+ ->toHaveCount (1 )
217+ ->and (User::searchIssueActor ('user 4 ' ))
218+ ->toHaveCount (1 );
219+
206220 // todo delete kısmı yazılmadı henüz
207221
208222});
You can’t perform that action at this time.
0 commit comments