# |
Oct 7th 2016, 12:47 |
dereuromark |
westy: custom sql is possible with $this->query($sql); A better approach, e.g. for a default admin account, is: ```php $data = [ [ 'username' => 'admin', 'email' => 'admin@example.com>', 'password' => '$2y$10$0NhsZCkmXa2tH11r5dBsF.e6d34MUt/z10JLfVDAivcuNoBJhopVq' ] ]; $table = $this->table('users'); $table->insert($data)-save(); ``` |
# |
Oct 7th 2016, 12:46 |
robodna |
When I create a 'nested resource route', the docs say to map the â??Commentsâ?? resource to the App\Controller\Articles\CommentsController... so do I create a src/Controller/Articles/CommentsController.php file? Also, what namespace do I include in this file.. namepsace App\Controller\Articles? |
# |
Oct 7th 2016, 12:41 |
pat |
ah I see it is not cake specific |
# |
Oct 7th 2016, 12:41 |
westy |
@dereuromark do I just add the data to the table in the up() function or do I call the seed class? |
# |
Oct 7th 2016, 12:34 |
pat |
I see, thank you. did I miss it in the docs or is it missing? |
# |
Oct 7th 2016, 12:33 |
dereuromark |
dont use the deprecated version, use getMockBuilder |
# |
Oct 7th 2016, 12:29 |
pat |
@dereuromark is it done with $this->getMock("path to component")? |
# |
Oct 7th 2016, 12:28 |
dereuromark |
westy: you can add basic seed data to migrations, yes |
# |
Oct 7th 2016, 12:28 |
dereuromark |
I tend to mock trump a lot these days |
# |
Oct 7th 2016, 12:27 |
dereuromark |
you can mock everything of course |
# |
Oct 7th 2016, 12:25 |
pat |
Gents, how can I mock components in CakePHP 3? is this possible? |
# |
Oct 7th 2016, 12:23 |
admad |
You can using the new FlashComponent |
# |
Oct 7th 2016, 12:22 |
tokam |
can I set two flash Messages? |
# |
Oct 7th 2016, 12:22 |
tokam |
$this->Session->setFlash( |
# |
Oct 7th 2016, 12:05 |
westy |
Can you run a seed from a Migration class file? |
# |
Oct 7th 2016, 12:04 |
westy |
I'm interested in how to deploy with data being added as well as the table structure, I have several tables that have pre-filled data |
# |
Oct 7th 2016, 12:03 |
westy |
Has anyone on here used Migrations and seeds for deployment? |
# |
Oct 7th 2016, 11:53 |
jameg83 |
@ypnos thanks I'll try this. |
# |
Oct 7th 2016, 11:51 |
ypnos |
jameg83: you could do !empty() instead |
# |
Oct 7th 2016, 11:48 |
jameg83 |
The problem is I'd used 'if isset' in my controller but a value of 0 would still cause this to return true as 0 is not null. Basic error.. Sorry guys. |
# |
Oct 7th 2016, 11:44 |
ypnos |
that's all it is |
# |
Oct 7th 2016, 11:44 |
ypnos |
it is a valid way of debugging to cancel out possible causes |
# |
Oct 7th 2016, 11:44 |
admad |
because your suggestion had nothing to do with the problem he was facing, but i guess you thought it was pertinent :slightly_smiling_face: |
# |
Oct 7th 2016, 11:43 |
ypnos |
why would you call it random? |
# |
Oct 7th 2016, 11:43 |
admad |
s/options/solutions |
# |
Oct 7th 2016, 11:42 |
admad |
ypnos: please don't suggest random options :slightly_smiling_face: it confuses someone who's already having trouble debugging/understanding an issue |
# |
Oct 7th 2016, 11:40 |
jameg83 |
Please ignore this... The issue is in my controller. Just checked the request body in the dev tools and it's sending value=0. So my view is doing the right thing. The problem it elsewhere. Sorry for confusion. |
# |
Oct 7th 2016, 11:40 |
admad |
@jameg83 if you submit without checking the post value will have 0 not 1 |
# |
Oct 7th 2016, 11:39 |
ypnos |
jameg83: did you try 'default' => false? |
# |
Oct 7th 2016, 11:32 |
jameg83 |
Hi everyone. Could any one please explain why the following:- $this->Form->input('shear', ['type' => 'checkbox', 'label' => 'Double Shear?']) returns a hidden field and a checkbox field with the value set to 1? The problem is when adding an entity this is set to true even if it's not checked.. |
# |
Oct 7th 2016, 11:30 |
ndm |
populating session data works just fine, given that the auth component is configured to use sessions of course |
# |
Oct 7th 2016, 11:28 |
doonot |
Hi all. Does anyone know how I can mock $this->Auth in a unit test in CakePHP 3? Putting Auth data into the session does not work as I use $this->Auth->user("id") in my code. |
# |
Oct 7th 2016, 11:26 |
tokam |
slackebot: thanks. it works with that |
# |
Oct 7th 2016, 11:24 |
pat |
Hi all. Does anyone know how I can mock $this->Auth in a unit test? Putting Auth data into the session does not work as I use $this->Auth->user("id") in my code. |
# |
Oct 7th 2016, 11:16 |
tokam |
ok thanks I will try to copy the user agen too |
# |
Oct 7th 2016, 11:12 |
ndm |
If a different IP causes the session to be invalidated, then this is likely either something implemented in the application, or you're doing more than just changing the IP. |
# |
Oct 7th 2016, 11:12 |
ndm |
@tokam Cakes session handler doesn't check the IP. In 2.x it may check the user agent string in case the `Session.checkAgent` option is enabled, in 3.x there aren't any such tests, only the regular timeout check. |
# |
Oct 7th 2016, 11:02 |
tokam |
ok as of I do sent it from an other ip I get logged out :( :D |
# |
Oct 7th 2016, 11:00 |
tokam |
string(80) "CAKE=616cesdsdsdsdsddsssssss3;PHPSESSID=bdsdssddsdsssssss" |
# |
Oct 7th 2016, 11:00 |
tokam |
the cookies look like this |
# |
Oct 7th 2016, 10:57 |
tokam |
*equal |