Log message #4223110

# At Username Text
# Jan 20th, 16:06 kiwi_72 on https://pastebin.com/TUSQt5Va i try to explain in more detail
# Jan 20th, 15:59 val @lorenzo I see `firstOrFail()` method that could be used as an example. That might work. What if I would like to do similar thing with `null` associated records returned by `find('all')` ?
# Jan 20th, 15:54 kiwi_72 When dumping the query i see no sign of the association when the model is set to hasMany, but I can see the other table when it is sat to hasOne(). Perhaps anyone could lighten me up what is going on here? thanks
# Jan 20th, 15:54 kiwi_72 Im stuck with cakephp 3.8's associated models. I think I have sat it up right, but I get nothing back from my find()->contains() if the association is set to hasMany(). By just changing the association to hasOne() inside the table it returns the first associated data row. Which is resonable, but I have no idea why it doesnt't work with hasMany().
# Jan 20th, 15:51 lorenzo you can override the query function in the table class to return your own query class instance
# Jan 20th, 15:50 lorenzo @val I would extend the Query class, and add a `firstOrDefault()` function
# Jan 20th, 15:49 kiwi_72 hello!
# Jan 20th, 15:48 val @lorenzo?
# Jan 20th, 15:45 neon1024 Question for Jose really, he wrote the ORM and would know better
# Jan 20th, 15:45 neon1024 As you can see here https://github.com/cakephp/cakephp/blob/3.8.8/src/ORM/ResultSet.php#L517
# Jan 20th, 15:44 neon1024 It sure does!
# Jan 20th, 15:43 val @neon1024 Thanks. `hydrate()` simply toggles the hydration.
# Jan 20th, 15:37 neon1024 Perhaps easier to implement a custom ResultSet class?
# Jan 20th, 15:37 neon1024 https://github.com/cakephp/cakephp/blob/3.8.8/src/ORM/ResultSet.php#L579
# Jan 20th, 15:36 neon1024 ..and associations
# Jan 20th, 15:36 neon1024 So that contained associations returned the new special type as well
# Jan 20th, 15:36 neon1024 https://github.com/cakephp/cakephp/blob/3.8.8/src/ORM/ResultSet.php#L522
# Jan 20th, 15:36 neon1024 You’d also want to do it for matching
# Jan 20th, 15:33 neon1024 …and doesn’t match the framework documentation and the code is often hidden and not obvious, making the behaviour hard to understand, unless you “just know it”
# Jan 20th, 15:32 neon1024 Although I’m not a fan of changes like this because it’s often undocumented and produces behaviour which isn’t consistent with the framework
# Jan 20th, 15:31 neon1024 That controls the conversion
# Jan 20th, 15:29 neon1024 I’d look at `_hydrate()` method in Query
# Jan 20th, 15:24 val @ndm, @admad what method should be overriden if I want that `Cake\ORM\Query->first()` would return a special object instead of `null` in case when no record is found in 3.x? I have difficulties in locating places where the entities are actually constructed.
# Jan 20th, 14:23 ricksaccous @admad nice if that's the case that might make things loads easier, i'm going to try that
# Jan 20th, 14:07 martin https://www.munderwood.ca/index.php/2017/02/28/responding-to-http-options-requests-in-cakephp/ this way
# Jan 20th, 14:07 martin fixed the options method with a middleware :)
# Jan 20th, 13:36 admad you can instead just use `$file->getStream()->getMetadata()['uri']` to get the file path to pass to flysystem
# Jan 20th, 13:35 ndm or reattach it
# Jan 20th, 13:35 admad so be sure you don't need to use the stream instance afterwards :)
# Jan 20th, 13:34 admad "After the stream has been detached, the stream is in an unusable state."
# Jan 20th, 13:33 ndm np
# Jan 20th, 13:33 ricksaccous Thanks
# Jan 20th, 13:32 ndm so `$upload->getStream()->detach()`
# Jan 20th, 13:32 ricksaccous Alright awesome I'll try detach
# Jan 20th, 13:32 ndm detach() will give you the resource ig neccesary
# Jan 20th, 13:32 mr.kusmadi @ricksaccous Use this $datas = $this->request->getData(); $datas['logo']->getClientMediaType(); //to check type of file $datas['logo']->getClientFilename(); //to get filename
# Jan 20th, 13:32 admad it's sad the flysystem doesn't directly support psr7 stream objects
# Jan 20th, 13:31 ricksaccous Or whatever that library is
# Jan 20th, 13:31 ricksaccous To feed it to FlySystem Adapters lol
# Jan 20th, 13:31 ndm Why would you want to do that?
# Jan 20th, 13:30 ricksaccous So how do I turn it into a resource after calling getStream()?