Logs for #cakephp

Page 8 of 36,478, showing 100 records out of 3,647,755 total, starting on record 701, ending on 800

# At Username Text
# Jan 20th, 22:14 mark.mikkelson select * from( select 'Chats' as Deal, id, date from Chats Union Select 'Tasks' as Deal, id, date, from Tasks Union Select 'Calls' as Deal, id, date from Calls ) Order by date
# Jan 20th, 22:05 ndm maybe explain what exactly you're looking for SQL wise
# Jan 20th, 22:04 mark.mikkelson yeah seems to just sort multiple them separatedly so each is sorted by created, just not all combined. I'll just write a function to sort it, was hoping there was some documentation I missed that would cover it :)
# Jan 20th, 21:59 mark.mikkelson I'll give it another bash just incase, thanks.
# Jan 20th, 21:59 mark.mikkelson thanks, although the docs only show sorting each association at a time and not as union from what I tested.
# Jan 20th, 21:57 challgren https://book.cakephp.org/3/en/orm/query-builder.html#sorting-contained-associations
# Jan 20th, 21:55 challgren `$this->Deals->find('all')->contain(['Tasks' => ['order' => 'created'], 'Calls' => ['order' => 'created'], 'Tickets' => ['order' => 'created'], 'Chats' => ['order' => 'created']])->where(['id'=>$id])->first();` would probably work
# Jan 20th, 21:52 mark.mikkelson Hey all, is there a way (cake3.8) to sort by a column across multiple tables. eg. I have something like this: $this->Deals->find('all')->contain(['Tasks', 'Calls', 'Tickets', 'Chats'])->where(['id'=>$id])->first(); Chats, Tickets, Calls and Tasks all have a created(datetime) column. I want to sort the results by created date across all those tables, but can't seem to find any docs on doing this?
# Jan 20th, 20:44 challgren https://book.cakephp.org/authorization/2/en/component.html#skipping-authorization
# Jan 20th, 20:43 luizcmarin I can't find the corresponding $ this-> Auth-> allow for cake 4. would it be $ this-> Authentication -> ....? Would anyone know?
# Jan 20th, 19:47 walid537 Ok thank you for your helping @admad :)
# Jan 20th, 19:39 admad plugin's are the official way to organize your app's MVC into modules
# Jan 20th, 19:39 admad definitely
# Jan 20th, 19:30 walid537 Thank you @admad , this solution it’s reliable for a big application?
# Jan 20th, 19:21 admad https://book.cakephp.org/4/en/plugins.html
# Jan 20th, 19:20 admad @walid537 use plugins
# Jan 20th, 18:41 turkles I'm still not clear what you need to do, or why - is there a problem you are trying to solve by changing the structure?
# Jan 20th, 18:36 walid537 It’s not possible to have a internal structure ?
# Jan 20th, 18:35 turkles You don
# Jan 20th, 18:30 walid537 Just edit mvc structure by modules/module_name/mvc
# Jan 20th, 18:30 walid537 To be able to separate my functionality by module without having 42 controllers files in the /controllers path
# Jan 20th, 18:28 turkles What are you trying to achieve?
# Jan 20th, 18:25 walid537 Hello everyone, I’m wondering if we can easy change MVC structure of CakePHP. Example : MVC Becomes -> modules/module_name/MVC ? Thanks for help.
# Jan 20th, 18:12 ricksaccous that's embarrasing
# Jan 20th, 18:12 ricksaccous now I have it working like a charm
# Jan 20th, 18:08 ricksaccous taht was stupid
# Jan 20th, 18:08 ricksaccous i have no idea why "find" didn't find the file though...
# Jan 20th, 18:07 ricksaccous i have to fix that up
# Jan 20th, 18:07 ricksaccous ```'basePath' => APP . 'data',```
# Jan 20th, 18:07 ricksaccous hahahaha
# Jan 20th, 18:07 ricksaccous instead of projectfolder/data
# Jan 20th, 18:07 ricksaccous it's writing the files to "src/data"
# Jan 20th, 18:07 ricksaccous oh crap lol
# Jan 20th, 18:04 ricksaccous def not an exact match though
# Jan 20th, 18:04 ricksaccous I've copied https://github.com/FriendsOfCake/cakephp-upload/blob/master/src/File/Writer/DefaultWriter.php a good amount, lol
# Jan 20th, 18:02 slackebot <ricksaccous>
# Jan 20th, 17:59 ricksaccous and when i try to do a find / filename ubuntu doesn't find anything
# Jan 20th, 17:59 ricksaccous i don't know what the heck is going on because when i do ```debug($filesystem->listContents('/Administrators/Profiles/'));``` I'm getting all the "files" that I had uploaded before but checking the actual directory i dont' see anything
# Jan 20th, 17:58 ricksaccous and when i want to create a file I'm using a path like /$dir1/$dir2/filename
# Jan 20th, 17:57 ricksaccous new Local($basePath);
# Jan 20th, 17:57 ricksaccous when i instantiate
# Jan 20th, 17:57 ricksaccous so I'm setting the local path to my project/data folder
# Jan 20th, 17:56 ndm @turkles I'm not sure that I can follow... but if you need to add indexes on query level, that's certainly possible, using for example a result formatter, something like: ```$query->formatResults(function (\Cake\Collection\CollectionInterface $results) { return $results->map(function ($row) { $row['roles'] = collection($row['roles']) ->indexBy('id') ->toArray(); return $row; }); });```
# Jan 20th, 17:51 ricksaccous @neon1024 using local
# Jan 20th, 17:38 turkles well atm I have checkboxes, with the checked state depending on current list, but when I submit it I want to remove and re-add where needed. Problem is I am paginating the list as there are too many, so I only want to remove/add items as required, which I can't do without some complex processing
# Jan 20th, 17:33 ndm `$hasRole = collection($user->roles)->firstMatch(['id' => $roleId]) !== null;`
# Jan 20th, 17:33 ndm If you just need it for a single check somewhere, then maybe just convert it to a collection and match it
# Jan 20th, 17:27 turkles I have a bunch of user roles my users can opt into, and finding it hard to check if they already have it as its User.Roles[0], User.Roles[1] etc, would be much easier if the index was role_id
# Jan 20th, 17:23 turkles Is it possible to index contains by a field/key?
# Jan 20th, 17:16 ndm `execute()` is a method of the inherited, "lower level" database query class, which has no ORM features like containments
# Jan 20th, 17:13 ndm @kiwi_72 Under the hood `get()` uses `find()` too. In your example you are using `execute()`, not sure if that's in your actual code, or just for the example, but that won't include containments, as it will only execute the SQL that this query object creates, not the ones created by the eager loadables (containments). Use `all()`, `toArray()`, one of the collection methos, or iterate the query object instead.
# Jan 20th, 17:06 kiwi_72 using get() works with the hasMany() association. something with find behaves differently than I expected it to be. @btx, @ndm thank you both for your pointers!
# Jan 20th, 16:55 neon1024 https://flysystem.thephpleague.com/v1/docs/adapter/local/
# Jan 20th, 16:54 neon1024 Are you using a local file system or a remote one?
# Jan 20th, 16:54 neon1024 The documentation for the Flysystem library says you set a path when you setup the adapter
# Jan 20th, 16:51 ricksaccous nothing makes sense here
# Jan 20th, 16:51 ricksaccous but not where
# Jan 20th, 16:51 ricksaccous I know they are somewhere
# Jan 20th, 16:50 ricksaccous I don't know where the hell my files are being put
# Jan 20th, 16:50 ricksaccous I'm running into a really stupid problem with flysystem
# Jan 20th, 16:26 kiwi_72 ok i see
# Jan 20th, 16:25 ndm It happens automatically under the hood, nothing you'd need to worry about
# Jan 20th, 16:25 kiwi_72 or you mean what is happening in tunder the hood of cakephp?
# Jan 20th, 16:25 kiwi_72 nothing I can find about additinal queries
# Jan 20th, 16:24 kiwi_72 in the examples on https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#retrieving-associated-data there is one find with contains, witch returns all the associated data
# Jan 20th, 16:24 ndm what procedure?
# Jan 20th, 16:24 kiwi_72 ndm: could you please elaborate on the procedure?
# Jan 20th, 16:22 ndm `hasMany` and `belongsToMany` associations are generally being retrieved in separate/additional queries
# Jan 20th, 16:20 kiwi_72 btx: i've got the query statements form the query object. and it is missing the association as soon as the table association is hasMany. (and vardumping the result is just accoring to this, it doesn't contain anything about the second table)
# Jan 20th, 16:19 lorenzo haha
# Jan 20th, 16:17 btx (my answers are always a trick to get a more qualified person to correct me)
# Jan 20th, 16:16 lorenzo contain is always eager
# Jan 20th, 16:16 lorenzo the orm does not lazy load
# Jan 20th, 16:16 btx the new ORM lazy loads, it probably wont pull it back unless asked to
# Jan 20th, 16:16 btx what happens when you actually vardump the executed object
# Jan 20th, 16:15 kiwi_72 I have checked with find() as you suggested, and it behaves the same
# Jan 20th, 16:15 btx because you’re using find(‘all’), probably
# Jan 20th, 16:14 kiwi_72 I see, but do you have any hints on why is the other table completely omitted in the query if the relation is hasMany() (with the same,and proven to work paramters (foreingKey/bindingKey)?
# Jan 20th, 16:09 btx also I wouldn’t specify the `hasMany` params unless you’re overriding them, but that’s just me
# Jan 20th, 16:09 btx kiwi, I would do `$ordersTable->find()->contain(['Tablebs'])` instead of `find('all')`
# 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