Repository navigation
fix(models): declare relation return types the console requests - #142
Merged
Merged
Conversation
core-api's RequestRelations only applies a client's with/expand/with_count name when the method declares an Eloquent Relation return type or the model lists it in $withable. Type the untyped relations the console asks for so they keep loading: - Store::networks(): BelongsToMany - Product::addonCategories/variants/files/hours(): HasMany - ProductAddonCategory::category(): BelongsTo - ProductVariant::options(): HasMany - StoreLocation::hours(): HasMany (its @return wrongly said BelongsTo) php-cs-fixer drops the now superfluous @return docblocks and shortens the remaining ones to the imported names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to fleetbase/core-api#303, which only lets a client's
with/expand/with_countname a method that declares an EloquentRelationreturn type, or one listed in$withable. Before #303, any public method with no required arguments could be called throughwith, for examplewith[]=saveInstanceinserted a blank row.Under #303, these relations would stop loading because the console requests them and they have no return type. This PR adds the return types:
routes/application.js)Merge order: merge this with #303 or before it. On today's core it changes nothing at runtime.
Fatal-error check: adding a return type is fatal for any subclass that overrides the method without one. I scanned every package for subclasses of these five models, following
extendschains transitively and matching names case-insensitively, plus anonymous test subclasses. None override a typed method. No core parent or trait defines these names.API / docs: no change in behaviour, so no fleetbase/postman or fleetbase.io update.
Other storefront
withrequests:orders/index/view.jssends awithlist thatOrderController::findRecordignores.alertIncomingOrderrequests fleetopsOrderrelations (customer,payload,trackingNumber), which are already typed.with: ['locations']reachesNetworkController@stores, which uses fixed relations.Validation
php -lon the 5 files: clean.php scripts/pest-runner.php server/tests: 689 tests, 0 failures, 23 errors. The base commit gives the same 23 errors in the same worktree. The local vendor copy lacksFleetbase\Support\SocketCluster\*andIlluminate\Validation\Factory, so these errors are not from this change.Tests: I added no new tests. The relation filtering is tested in core-api #303, and this PR only adds declarations.