DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
515 stars 44 forks source link

[Bug] toArray() error on members() #650

Closed zoriax closed 1 year ago

zoriax commented 1 year ago

Hi @stevebauman

I have an error on Group model with members()->get()->toArray(). It finisehd with

Fatal error: Uncaught Error: Call to a member function toDateTimeString() on bool in \LdapRecord\Traits\ProcessAttributes.php:438 Stack trace: #0

As a workaround, this work fine :

->members()->get()->map(fn($grp) => $grp->name)->toArray()

Could you please check that ?

Thanks !

stevebauman commented 1 year ago

Hi @zoriax!

Fatal error: Uncaught Error: Call to a member function toDateTimeString() on bool in \LdapRecord\Traits\ProcessAttributes.php:438 Stack trace: #0

This trait isn't apart of the LdapRecord package. Is what you've shown the only logic taking place inside?

Also, have you added any additional $casts to an LdapRecord model that may be causing this?


EDIT In fact, this method (toDateTimestring) is never actually called anywhere in the core LdapRecord source -- only inside of the test suite:

https://github.com/search?q=repo%3ADirectoryTree%2FLdapRecord%20toDateTimeString&type=code

zoriax commented 1 year ago

Hi @stevebauman,

Sorry for my late answer. You are totally right, the problem was on my own ;-) !

Don't waste your time and sorry for that...

stevebauman commented 1 year ago

No worries @zoriax! Appreciate you replying here and closing this out 🙏