File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 77use Illuminate \Http \Request ;
88use Illuminate \Http \Resources \PotentiallyMissing ;
99use Illuminate \Support \Collection ;
10+ use Illuminate \Support \Facades \App ;
1011use TiMacDonald \JsonApi \Support \Fields ;
1112
1213/**
1314 * @internal
1415 */
1516trait Attributes
1617{
17- private static bool $ minimalAttributes = false ;
18+ private const MINIMAL_ATTRIBUTES_KEY = self ::class. ' :$minimalAttributes ' ;
1819
1920 /**
2021 * @return void
2122 */
2223 public static function minimalAttributes ($ value = true )
2324 {
24- self ::$ minimalAttributes = $ value ;
25+ App:: instance ( self ::MINIMAL_ATTRIBUTES_KEY , $ value) ;
2526 }
2627
2728 /**
@@ -52,6 +53,13 @@ private function resolveAttributes(Request $request)
5253 */
5354 private function requestedFields (Request $ request )
5455 {
55- return Fields::getInstance ()->parse ($ request , $ this ->toType ($ request ), self ::$ minimalAttributes );
56+ return Fields::getInstance ()->parse ($ request , $ this ->toType ($ request ), self ::resolveMinimalAttributes ());
57+ }
58+
59+ private static function resolveMinimalAttributes (): bool
60+ {
61+ return App::bound (self ::MINIMAL_ATTRIBUTES_KEY )
62+ ? (bool ) App::make (self ::MINIMAL_ATTRIBUTES_KEY )
63+ : false ;
5664 }
5765}
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ protected function tearDown(): void
2929 parent ::tearDown ();
3030
3131 JsonApiResource::resolveServerImplementationNormally ();
32- JsonApiResource::minimalAttributes (false );
3332 }
3433
3534 protected function assertValidJsonApi (TestResponse |string |array $ data ): void
You can’t perform that action at this time.
0 commit comments