# |
Oct 11th 2019, 12:35 |
aivaras.godliauskas |
@jeremy.halin i believe only ```beforeSave``` is enough |
# |
Oct 11th 2019, 12:35 |
ndm |
@rchavik That's years before `cakephp/authentication` and `cakephp/authorization` even existed... maybe you were referring to something I don't see over here. |
# |
Oct 11th 2019, 12:34 |
jeremy.halin |
or do I need a behavior ? |
# |
Oct 11th 2019, 12:32 |
jeremy.halin |
@ndm thanks, can I just create a `beforeSave` function in my `table` ? |
# |
Oct 11th 2019, 12:31 |
ndm |
@jeremy.halin https://book.cakephp.org/3.0/en/orm/behaviors.html#defining-event-listeners https://book.cakephp.org/3.0/en/tutorials-and-examples/bookmarks/part-two.html#persisting-the-tag-string |
# |
Oct 11th 2019, 12:21 |
jeremy.halin |
Hi, I would like to create and save a column value based on another automatically. I have a local time in a column and want to store that same time but converted to UTC in another column. Rather than doing so in each save or update, I would like to make it automatic. I've seen https://book.cakephp.org/3.0/en/orm/table-objects.html#lifecycle-callbacks but it's unclear for me. Anyone with a concrete example please ? Thanks. |
# |
Oct 11th 2019, 12:14 |
ndm |
@jotpe It may help if you'd show your code... have you checked https://github.com/cakephp/authorization/issues/79 ? |
# |
Oct 11th 2019, 12:14 |
ndm |
That's... a totally different question ;) Look at for example https://github.com/UseMuffin/Footprint, injecting the data via events is usually the way to go. |
# |
Oct 11th 2019, 11:29 |
rochasmarcelo |
In your controller, ``` $user = $this->Auth->user(); ``` or ```$userId = $this->Auth->user('id');``` |
# |
Oct 11th 2019, 11:26 |
jotpe |
How can i solve this |
# |
Oct 11th 2019, 11:25 |
jotpe |
I implement `Authentication\IdentityInterface` and `Authorization\IdentityInterface` on my user |
# |
Oct 11th 2019, 11:25 |
jotpe |
If I use Authentication with Authorization Plugin with a custom Deocrator on my User I get `Call to undefined method Authentication\Identity::setAuthorization()` |
# |
Oct 11th 2019, 09:59 |
jotpe |
(E.g. If I have different user groups) |
# |
Oct 11th 2019, 09:59 |
johnwayne |
@ndm thanx, `$getAllOpenOrders->toArray()` was the problem (it was not the array |
# |
Oct 11th 2019, 09:59 |
jotpe |
For the Authorization Plugin: I have several Policies and a AdminPolicy which implements BeforePolicyInterface to grant Admin Access. For now I extend all my Policies, but I wonder if there's a more advanced solution? |
# |
Oct 11th 2019, 09:32 |
ndm |
Are you sure that this is the query that is causing it? Also are you sure `$getAllOpenOrders` is an array (and not maybe a query)? And what is `$status`? What exactly does the generated SQL look like? That error usually happens when the table that you want to update is referenced in for example a join or a subquery. |
# |
Oct 11th 2019, 09:23 |
slackebot1 |
update in FROM clause` |
# |
Oct 11th 2019, 09:23 |
johnwayne |
Hi to all, if I try to update multiple records in the single table I am getting error... There is my Query ``` $updateAll = TableRegistry::getTableLocator()->get('Items') ->query() ->update() ->set(['status' => $status]) ->where(['order_id IN ' => $getAllOpenOrders]) ->execute(); $getAllOpenOrders = array with all relevant ids ``` The error is `You can't specify target table 'items' for |
# |
Oct 11th 2019, 09:07 |
peter |
im using cakephp 3 |
# |
Oct 11th 2019, 09:06 |
peter |
Hi, how do I get the the authenticated user id when i use cakedc/users plugin |
# |
Oct 11th 2019, 08:17 |
neon1024 |
Morning all :wave: |
# |
Oct 11th 2019, 07:56 |
nk-sonu |
Issue has been solved using recursive =3 |
# |
Oct 11th 2019, 07:36 |
slackebot1 |
'foreignKey' => 'lead_id'` ` )` ` )` ` )` `);` `$this->paginate = array(` ` 'conditions' => array('FollowupMaildeliver.user_id' => 2),` ` 'contain' => array('Lead'),` ` 'limit' => 20, ` ` 'order' => 'FollowupMaildeliver.id DESC'` `);` `$data = $this->paginate('FollowupMaildeliver');` |
# |
Oct 11th 2019, 07:36 |
nk-sonu |
hi, i was working on a CakePHP 2 project, its an old project. i am trying to fetch association data but "Lead" model data not coming under "FollowupEmail" model. please guide. `$this->loadModel('FollowupMaildeliver');` `$this->loadModel('FollowupEmail');` `$this->loadModel('Lead');` `$this->FollowupEmail->bindModel(` ` array('belongsTo' => array(` ` 'Lead' => array(` ` 'className' => 'Lead',` ` |
# |
Oct 11th 2019, 07:05 |
jotpe |
Morning |
# |
Oct 11th 2019, 06:44 |
alexdd55976 |
morning |
# |
Oct 11th 2019, 05:48 |
spriz |
especially for larger stuff :) |
# |
Oct 11th 2019, 05:48 |
spriz |
it's tough job for PHP to do that |
# |
Oct 11th 2019, 05:48 |
spriz |
I do not believe one will make this too easy |
# |
Oct 11th 2019, 05:48 |
kgb.acct.personal |
I thought there's something like `$collection->sortBy(['field1', 'field2'])` |
# |
Oct 11th 2019, 05:48 |
spriz |
I see - then I would do something like that :slightly_smiling_face: |
# |
Oct 11th 2019, 05:48 |
kgb.acct.personal |
Nope. The collection is from request data. |
# |
Oct 11th 2019, 05:46 |
spriz |
no way to do this in SQL/ |
# |
Oct 11th 2019, 05:46 |
spriz |
and do something like `return $fieldOne . '-' . $fieldTwo` but that can get messy and slow pretty quickly for lager collections :S |
# |
Oct 11th 2019, 05:45 |
spriz |
I guess you would need to use a function in the `->sort()` |
# |
Oct 11th 2019, 05:45 |
kgb.acct.personal |
@spriz Yes. Also assuming that those fields have different types |
# |
Oct 11th 2019, 05:44 |
spriz |
first by field 1, and then by field 2? |
# |
Oct 11th 2019, 05:44 |
spriz |
@kgb.acct.personal how would that be sorted? |
# |
Oct 11th 2019, 05:39 |
kgb.acct.personal |
How do I sort Collection using two fields? |
# |
Oct 11th 2019, 03:04 |
arai.mio.i |
Thank you! |
# |
Oct 11th 2019, 02:53 |
challgren |
@arai.mio.i `$query->enableHydration(false)` https://book.cakephp.org/3.0/en/orm/query-builder.html#getting-arrays-instead-of-entities |