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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Form Request and Tests for Update Asset API Method #14458
base: snipeit_v7_laravel10
Are you sure you want to change the base?
Add Form Request and Tests for Update Asset API Method #14458
Changes from 31 commits
c025e25
eac0186
b239b3a
c8341d9
eb8f1dd
6732b66
04d7884
8962ced
f01b205
f6ab0f8
86ab880
c0110e7
1e810d2
0ffceb9
b4b4927
e1addc5
fdf0be0
c155e4a
d18aa1d
e3e01e0
e7b9903
8cc1397
be282dd
60ca634
39c15b2
013463a
701411c
1d4a7a7
cec84b8
4ab75c1
0a90df2
53ccd19
b11c900
107f8db
8696a42
03f091a
97a6152
8b3ff5a
cdb1140
8ce577d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get these three rules - where we are removing the 'required' attribute. But a lot of the rest of the rules look exactly the same as the rules on the model. Can we do a kind-of 3-way
array_merge()
here, where we grab the Asset's$rules
(or mayberules()
?), override these couple of ones where we need to pull therequired
attribute, then grab theparent::rules()
and merge those in too? I feel like that would cut down on the duplication. Or, another way you could go - grab theAsset::rules
, and grep-out the 'required' attributes, and merge in the parent::rules()?I just hate repeating rules in multiple places and fear that if we change some constraint somewhere - let's say, we decide to make 'name' have a max of 1023 characters for example - then having to go and update that in 4 or more places. That feels like a foot-gun waiting to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I've put a couple of different options for resolving this in the
rules()
method -$rules
&$rules2
One quick thing, the conversion of the rule strings to arrays in the model is not necessary if we go with option 1 (
$rules
) - converting them to arrays just makes it a little easier to manipulate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can not figure out how to get rid of this, sorry 🙄