laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

Respect Laravel's new accessors

Open mrneatly opened this issue 3 years ago • 5 comments

Fix getting a value from \Illuminate\Database\Eloquent\Casts\Attribute-returning accessors (issue #2363).

mrneatly avatar May 28 '22 06:05 mrneatly

Codecov Report

Merging #2394 (5a5eb96) into master (f4c448f) will increase coverage by 0.01%. The diff coverage is 100.00%.

:exclamation: Current head 5a5eb96 differs from pull request most recent head 5d292a2. Consider uploading reports for the commit 5d292a2 to get more accurate results

@@             Coverage Diff              @@
##             master    #2394      +/-   ##
============================================
+ Coverage     87.62%   87.63%   +0.01%     
- Complexity      676      677       +1     
============================================
  Files            31       31              
  Lines          1551     1553       +2     
============================================
+ Hits           1359     1361       +2     
  Misses          192      192              
Impacted Files Coverage Δ
src/Eloquent/Model.php 93.71% <100.00%> (+0.08%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar May 28 '22 08:05 codecov-commenter

Whats the status of this PR?

CraigMonva avatar Jul 11 '22 15:07 CraigMonva

I've managed to fix the issue, but the cs-fixer denied my code for some reason. As the code in php-cs-fixer details doesn't give any clue, I would be very happy if anyone could explain me, what exactly I have to fix in order to have my pull request accepted :)

mrneatly avatar Jul 11 '22 16:07 mrneatly

This is a breaking change and is this related to embedded relation?

divine avatar Jul 12 '22 07:07 divine

@divine this change isn't specifically related to an embedded relation as this case may also happen when using other types of relations. I'm not sure if it's really a breaking change because all this code does is performs an additional check whether requested attribute returns an Attribute object or not. Without that change, a null s being returned in case of a one-worded attribute, which is obviously a bug.

mrneatly avatar Jul 25 '22 08:07 mrneatly

Closed in favor of #2438.

divine avatar Aug 31 '22 19:08 divine