File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 99class ApiCollection extends ResourceCollection
1010{
1111
12+ /**
13+ * Guard used to retrieve the user from the request.
14+ * null defaults to default guard config (auth.defaults.guard)
15+ *
16+ * @var ?string
17+ */
18+ protected ?string $ guard = null ;
19+
20+ public function setGuard (string $ guard ): static
21+ {
22+ $ this ->guard = $ guard ;
23+
24+ return $ this ;
25+ }
26+
1227 protected ?string $ fieldKey = null ;
1328
1429 protected function collects ()
@@ -31,7 +46,7 @@ public function setFieldKey(?string $fieldKey): static
3146 public function toArray (Request $ request )
3247 {
3348 return $ this ->collection ->map (
34- fn ($ item ) => $ item ->setFieldKey ($ this ->fieldKey )->toArray ($ request )
49+ fn ($ item ) => $ item ->setGuard ( $ this -> guard )-> setFieldKey ($ this ->fieldKey )->toArray ($ request )
3550 )->all ();
3651 }
3752}
You can’t perform that action at this time.
0 commit comments