File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717### Changed
1818- Refactored ` QueryBuilder ` and ` ApiModel ` to use the new ` ParsesApiResponse ` trait, removing duplicate ` parseResponse ` implementations.
1919
20+ ### Fixed
21+ - Remote models hydrated from API responses are marked as existing to prevent local database queries.
2022
2123## [ 0.4.1] - 2025-07-10
2224### Added
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ public static function fromApiResponse(array $data): static
2424 {
2525 $ instance = new static ();
2626
27+ // Handle API relations defined in the model
2728 foreach (static ::$ apiRelations as $ relation => $ cast ) {
2829 if (array_key_exists ($ relation , $ data )) {
2930 $ instance ->setRelation (
@@ -34,8 +35,14 @@ public static function fromApiResponse(array $data): static
3435 }
3536 }
3637
38+ // Fill the model with the remaining data
3739 $ instance ->fill ($ data );
3840
41+ // Mark the instance as existing to prevent local database queries
42+ if (property_exists ($ instance , 'exists ' )) {
43+ $ instance ->exists = true ;
44+ }
45+
3946 return $ instance ;
4047 }
4148
You can’t perform that action at this time.
0 commit comments