Fixed #12531 Expected Checkin Date on Asset Checkout throws an error #12537
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.
Description
When an asset get checkout, the user can set a date for the day they expected the asset to got checkin. We made a couple days ago that the
expexted_checkin
value came in the formY-m-d
but whenever this value is set, the validation always fails. This was caused because for some reason, Laravel put the asset object together with that date as formatY-m-d H:i:s
So I tested various forms to make this works as expected. And my results where this:
'expected_checkin' => 'date_format:Y-m-d|nullable',
to'expected_checkin' => 'date_format:Y-m-d H:i:s|nullable',
. This way the validation pass and the date still is saved asY-m-d
in the database, but I don't like that we are expressing in the code something we really don't like.expected_checkin
field from theprotected $dates
array. This way the validation pass but I don't like that we are not putting a date field with the others, and also we have dates in this array that fulfill the needed format.purchase_date
have in SnipeModel model class. I read the code and see this field have the same format as we need. It's defined in the Snipe model class because thepurchase_date
field is common to a lot of types of assets. So I put it in the Asset model class because theexpected_checkin
field only is used in asset types. We can see that using the setter, the object is formed with this attribute in the correct format.As always let me know if there is a more elegant/simpler solution. This was the only way I could figure out.
Fixes #12531
Type of change
How Has This Been Tested?
Test Configuration: