Log message #4055457

# At Username Text
# Jul 21st 2017, 14:37 birdy247 I am dispatching that from my SettingsTable
# Jul 21st 2017, 14:37 jeremyharris if the field is hidden, the security component will protect it from being tampered with
# Jul 21st 2017, 14:37 birdy247 $event = new Event('Model.Settings.afterStart', $this, [ 'start' => $start ]);
# Jul 21st 2017, 14:37 jay Or use SESSION
# Jul 21st 2017, 14:37 jay Hidden values you can maintain with a hash
# Jul 21st 2017, 14:36 mirec yep, set it manually or you can validate it
# Jul 21st 2017, 14:36 mikesmoniker The Security component can prevent people from messing with which fields are submitted but I don’t think it works on values. You’d probably need to just manually set model in your action or use a model event to set it based on something.
# Jul 21st 2017, 14:35 devito i think i read somethign about it in the cookbook but dont recall off the top of my head
# Jul 21st 2017, 14:34 devito is there a way to prevent form tampering? I want to explictly set the model name in my forms and dont want a user inspecting and changing it on me
# Jul 21st 2017, 14:33 devito yea that would be a bad thing to forget hehe
# Jul 21st 2017, 14:33 devito mm
# Jul 21st 2017, 14:33 mirec do not forget two column index on (model, foreign_key) in your images table
# Jul 21st 2017, 14:32 devito yea
# Jul 21st 2017, 14:32 mirec yep I see... so Posts->hasMany('Images', ['conditions' => ['model' => 'Posts'], 'foreignKey' => 'foreign_key'])
# Jul 21st 2017, 14:31 devito a post can have many images
# Jul 21st 2017, 14:31 devito yea im tinkering with the assoiation configs now
# Jul 21st 2017, 14:31 mirec why do you have foreign_key in images table? why not Posts.image_id ?
# Jul 21st 2017, 14:30 devito I would just simply need to update the model column to point to the correc tmodel
# Jul 21st 2017, 14:30 devito smae for $this->Page->Image->path using the same table but without traditional foreign keys. Because if i make a new content type i dont want to have to add a new column to the db to accomidate it
# Jul 21st 2017, 14:29 mirec have you tried associations "conditions" config?
# Jul 21st 2017, 14:28 devito i want to be able to do $this->Post->iamge
# Jul 21st 2017, 14:26 mirec so you want something like $image->owner to be Post or Page ?
# Jul 21st 2017, 14:26 mikesmoniker @devito Something like https://github.com/robotusers/cakephp-table-inheritance might be a starting point.
# Jul 21st 2017, 14:26 devito setting to be saved that is...
# Jul 21st 2017, 14:25 devito my biggest concern with this approach is setting the entity data correctly.
# Jul 21st 2017, 14:24 mirec yep I got it, let me think
# Jul 21st 2017, 14:24 devito so the images table would be polymorphic as it belongs to both pages and posts but we would use foreign key and model to designate which one
# Jul 21st 2017, 14:23 devito imagine a images table that belongs to posts and pages however insted of a post_id / page_id we have a foreign_key and model column
# Jul 21st 2017, 14:22 mirec devito: what do you mean
# Jul 21st 2017, 14:22 devito has anyone experimented with polymorphic models in 3.x?
# Jul 21st 2017, 14:22 devito hello all
# Jul 21st 2017, 14:21 gutts yup filter does it. sweet thanks mirec
# Jul 21st 2017, 14:17 mirec https://book.cakephp.org/3.0/en/orm/query-builder.html#adding-calculated-fields
# Jul 21st 2017, 14:16 mirec on your resultset try $resultSet->filter(function($post){return count($post->comments) > 1})
# Jul 21st 2017, 14:15 mirec I do not think cachecounter will be helpful since you need Comments filtered dynamically by user_id
# Jul 21st 2017, 14:14 gutts or a cache counter
# Jul 21st 2017, 14:14 gutts ok, ill try to use mapreduce for that
# Jul 21st 2017, 14:13 mikesmoniker Is there a trick to getting cakephp-queuesadilla to use Predis? When I specify a className in the config, it gets overwritten to Redis because the DSN starts with redis://. cc @savant
# Jul 21st 2017, 14:12 mirec hasMany generates another query, so you cant use simple having mysql syntax. alternatively you can try CollectionTrait::filter()
# Jul 21st 2017, 14:09 mirec try mapReduce https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#map-reduce
# Jul 21st 2017, 14:01 gutts what about the having, how do i reference comments in relation to that?