# |
Jul 20th 2021, 11:36 |
paolo.bragagni |
Books has many Categories |
# |
Jul 20th 2021, 11:20 |
ndm |
The `_ids` key is not ment to hold a flat value, but an array of values. You probably need to be a bit more specific as to where exactly in your associated data you want to store something, and what that something actually looks like (data structure wise). |
# |
Jul 20th 2021, 10:54 |
paolo.bragagni |
I mean I'd like to save a specific value with an hidden field |
# |
Jul 20th 2021, 10:25 |
paolo.bragagni |
I'd like to save $return['returncontrollerid'] |
# |
Jul 20th 2021, 10:24 |
paolo.bragagni |
echo $this->Form->hidden('{{ assocData.property }}._ids', ['value' => $return['returncontrollerid']]); |
# |
Jul 20th 2021, 10:24 |
paolo.bragagni |
hi how to save specific value in form BelongsToMany? |
# |
Jul 20th 2021, 10:08 |
dereuromark |
here it is twice as important to check that all incoming values are properly sanitized though. and there is no room for "injection" of any kind of data. |
# |
Jul 20th 2021, 09:58 |
dereuromark |
if it is just about simple boolean toggles, I usually also just use updateAll() as atomic operation. Simpler if you don't need validation or alike on top. |
# |
Jul 20th 2021, 09:53 |
erwane |
$article->set($fieldName, $value) |
# |
Jul 20th 2021, 09:48 |
kupe3b |
thanks. which function can i call instead of `$article->published=1` for example (in case i pass the field name as an argument)? |
# |
Jul 20th 2021, 09:45 |
dereuromark |
field name can just be the argument, yes |
# |
Jul 20th 2021, 09:44 |
dereuromark |
that methods looks easily breakable, as publish can now also unpublish.. |
# |
Jul 20th 2021, 09:32 |
kupe3b |
hi, I have a very simple method to switch a yes/no field: ``` public function publish($id) { $article = $this->Articles->get($id); $article->published=!$article->published; $this->Articles->save($article) }``` but how can i change it to accept the field name as an argument? `public function publish($id, $fieldName='published')` to be able to change state of the other yes/no fields from `articles` table? |
# |
Jul 20th 2021, 08:14 |
ndm |
What I ment was... don't use WSL, try a dedicated virtual machine. |
# |
Jul 20th 2021, 08:09 |
brandon |
I can't seem to find any error logs or anything so I am not sure where it is even getting stuck to try to remedy it. |
# |
Jul 20th 2021, 08:00 |
paolo.bragagni |
yes. it works rerunning bin/cake bootstrap install |
# |
Jul 20th 2021, 07:58 |
brandon |
Is there a way to make the changes without rector? |
# |
Jul 20th 2021, 07:55 |
rudy1976s |
@greg138 I have a fixture with a json field which contains some values: when I run the test on that table, the json field is not properly read |
# |
Jul 20th 2021, 07:48 |
paolo.bragagni |
(trying..) |
# |
Jul 20th 2021, 07:35 |
paolo.bragagni |
I have to rerun bin/cake bootstrap install ? |
# |
Jul 20th 2021, 07:30 |
ndm |
@brandon tag |
# |
Jul 20th 2021, 07:30 |
paolo.bragagni |
hi. I've updated from 3.0.1 to 3.1.1 and it doesnt find css |
# |
Jul 20th 2021, 07:30 |
ndm |
Try running it in a fresh linux based VM, from my experience that's your best chance. Rector is a little wimp that already breaks when it hears the wind blowing. |
# |
Jul 20th 2021, 07:27 |
ndm |
Rector not working? I am shooketh! SHOOKETH I say! |
# |
Jul 20th 2021, 07:06 |
slackebot2 |
--working-dir='/mnt/d/Programming/PHP/vintage-lib/src' '/mnt/d/Programming/PHP/vintage-lib/src'``` I have tried this both in and out of WSL. Not sure what it is doing or what I can check. Any ideas? |
# |
Jul 20th 2021, 07:06 |
brandon |
Having issues with upgrading to 4.x. I am following the upgrade guide and I have gotten to the Rector portion. When I run the command `bin/cake upgrade rector --dry-run ../vintage-lib/src -v` (added `--dry-run` and `-v` to see if I get any output at all). This is what I get and it just hangs here: ```$ bin/cake upgrade rector --dry-run ../vintage-lib/src -v Detecting autoload file for /mnt/d/Programming/PHP/vintage-lib/src -> |
# |
Jul 20th 2021, 07:06 |
slackebot2 |
Checking /mnt/d/Programming/PHP/vintage-lib/src/vendor/autoload.php -> Checking /mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php -> Found /mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php Running /mnt/d/Programming/PHP/upgrade/vendor/bin/rector process --dry-run --autoload-file='/mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php' --config='/mnt/d/Programming/PHP/upgrade/config/rector/cakephp40.php' |
# |
Jul 19th 2021, 19:38 |
kevin.pfeifer |
definitely handy when it comes to “heavier” tasks which can’t be done (quickly enough) inside a normal web request ;) |
# |
Jul 19th 2021, 19:37 |
sebastiansperandio093 |
I will check it! |
# |
Jul 19th 2021, 19:37 |
sebastiansperandio093 |
ohh I saw it before! thanks! |
# |
Jul 19th 2021, 19:34 |
kevin.pfeifer |
I think you would definitely benefit from a queue system where you add your internal “process the payment updates” to an async background job while your main response delivers your 200. I would recommend https://github.com/dereuromark/cakephp-queue :P |
# |
Jul 19th 2021, 19:30 |
dereuromark |
those sound like 2 different requests, which at least one of them is a async (queue background) task. |
# |
Jul 19th 2021, 19:30 |
alamnaryab |
@greg138 :+1: |
# |
Jul 19th 2021, 19:29 |
sebastiansperandio093 |
@kevin.pfeifer not exactly....they are just notifying me when a payment status is updated. So they asking me a notification URL to send 2 parameters....i.e: https://www.domain.com?topics=paymentsandid=123456 they have a retry process for these notifications. If you dont response 200 after 22 seconds (I know it is toooo time), they have a retry schedule. This is why they recommend that you respond 200 first and then |
# |
Jul 19th 2021, 19:29 |
slackebot2 |
do your job (for example, update your db with the payment updates) |
# |
Jul 19th 2021, 19:23 |
greg138 |
Then, `->contain(['StudentTransports.RouteStops.TransportRoutes'])` would give you what you're looking for? |
# |
Jul 19th 2021, 19:22 |
alamnaryab |
yes |
# |
Jul 19th 2021, 19:22 |
greg138 |
@alamnaryab, your RouteStops table is associated with both StudentTransports and TransportRoutes? |
# |
Jul 19th 2021, 19:20 |
kevin.pfeifer |
@sebastiansperandio093 so your API requires a 200 (or 201) response as a “yea, got it, I’m working on it” and at a later point another 200 after its done? You can’t send 2 responses to 1 request, how should that work? I think you misunderstand the API documentation. |
# |
Jul 19th 2021, 19:14 |
sebastiansperandio093 |
you could use "use" |
# |
Jul 19th 2021, 19:12 |
alamnaryab |
Hi is it possible to access proprty of parent Model in contained model ```$student = $this->Students->find() ->where(['Students.id' => $id]) ->contain( [ 'StudentTransports', 'StudentTransports.TransportRoutes', 'StudentTransports.TransportRoutes.RouteStops'=>function($q){ //can I access |
# |
Jul 19th 2021, 19:12 |
slackebot2 |
StudentTransports.route_stop_id here //bcz without condition it is showing all records of RouteStops return $q->where(['RouteStops.id'=> /*????**/]); } ] )->first();``` or any other better way to get multi level nested contained queries |
# |
Jul 19th 2021, 19:10 |
sebastiansperandio093 |
I could omit this recommendations as a B plan |
# |
Jul 19th 2021, 19:09 |
sebastiansperandio093 |
is an payment gateway API, and it is sending notifications about pending payments and it expects a 200 status code. |
# |
Jul 19th 2021, 19:08 |
sebastiansperandio093 |
yes I totally agree about it is a bad design, but API documentation recommends send a response before working. |
# |
Jul 19th 2021, 19:04 |
dereuromark |
you can (and should) return the response instead. And then maybe a afterFilter callback or middleware could still be applied. not sure. but either way, this sounds like a bad design. |
# |
Jul 19th 2021, 18:58 |
kevin.pfeifer |
well what is the reason that it should actually happen after the response and not before? |
# |
Jul 19th 2021, 18:55 |
sebastiansperandio093 |
response code should be 200 or 201 |
# |
Jul 19th 2021, 18:55 |
sebastiansperandio093 |
it doesnt work |
# |
Jul 19th 2021, 18:55 |
sebastiansperandio093 |
```$this->response = $this->response->withStatus(201); $this->response->send(); echo 'hello';exit;``` |
# |
Jul 19th 2021, 18:54 |
sebastiansperandio093 |
hello everyone, can I send a response 200 and continue processing php after sending it? |
# |
Jul 19th 2021, 17:13 |
admad |
"Task failed successfully" |
# |
Jul 19th 2021, 17:10 |
tyler.adam.lazenby |
I had just migrated from using users to reference contacts to accounts |
# |
Jul 19th 2021, 17:10 |
tyler.adam.lazenby |
i found the issue |
# |
Jul 19th 2021, 17:10 |
kevin.pfeifer |
because according to https://github.com/dereuromark/cakephp-queue/blob/c7f0386218387d7fd9dba2781449fcfbb984e59d/src/Queue/Processor.php#L206 you get that message in the worker if any exception is being thrown inside your task |
# |
Jul 19th 2021, 17:10 |
tyler.adam.lazenby |
Gawwww |
# |
Jul 19th 2021, 17:09 |
tyler.adam.lazenby |
I am importing data from a csv file into my database to create or update contacts |
# |
Jul 19th 2021, 17:08 |
kevin.pfeifer |
can you maybe provide the content of your task you try to run with the worker? |
# |
Jul 19th 2021, 17:04 |
tyler.adam.lazenby |
yes |
# |
Jul 19th 2021, 17:03 |
kevin.pfeifer |
so your task can successfully be added to the queue but when the worker tries to process it you get "task did not finish" ? |
# |
Jul 19th 2021, 17:02 |
tyler.adam.lazenby |
job did not finish |
# |
Jul 19th 2021, 17:01 |
tyler.adam.lazenby |
looking into that |
# |
Jul 19th 2021, 17:01 |
tyler.adam.lazenby |
now I am just getting "task did not finish" |
# |
Jul 19th 2021, 17:01 |
tyler.adam.lazenby |
No |
# |
Jul 19th 2021, 16:57 |
kevin.pfeifer |
did that fix your problem? |
# |
Jul 19th 2021, 16:46 |
tyler.adam.lazenby |
thank you |
# |
Jul 19th 2021, 16:43 |
tyler.adam.lazenby |
I will now |
# |
Jul 19th 2021, 16:42 |
kevin.pfeifer |
have you read https://github.com/dereuromark/cakephp-queue/tree/master/docs#coming-from-v5-to-v6 ? |
# |
Jul 19th 2021, 16:41 |
tyler.adam.lazenby |
help |
# |
Jul 19th 2021, 16:33 |
tyler.adam.lazenby |
```2021-07-19 10:32:35 Error: [PDOException] SQLSTATE[42S22]: Column not found: 1054 Unknown column 'QueuedJobs.job_task' in 'where clause' in C:\xampp\htdocs\ezBusinessManager\vendor\cakephp\cakephp\src\Database\Statement\MysqlStateme nt.php on line 39``` |
# |
Jul 19th 2021, 16:16 |
dereuromark |
As for the naming, I see an issue of `implements addInterface` vs AddInterface (casing matters), but it might not be relevant for this case. |
# |
Jul 19th 2021, 16:16 |
dereuromark |
Tip: upgrade to v6, it has a few better ways to directly detect issues with e.g. naming |
# |
Jul 19th 2021, 16:15 |
tyler.adam.lazenby |
https://pastebin.com/SBWFhtzm |
# |
Jul 19th 2021, 16:14 |
tyler.adam.lazenby |
https://pastebin.com/ifdkDas5 |
# |
Jul 19th 2021, 16:13 |
tyler.adam.lazenby |
ok \ |
# |
Jul 19th 2021, 16:12 |
dereuromark |
You might need to "pastebin" the whole code, incl path, maybe someone sees your mistake |
# |
Jul 19th 2021, 16:11 |
tyler.adam.lazenby |
and I have run the phpstorm generate and the annotate all |
# |
Jul 19th 2021, 16:11 |
tyler.adam.lazenby |
yes |
# |
Jul 19th 2021, 16:11 |
dereuromark |
something, usually a typo somewhere, or missing use statement. are you using PHPStorm or a high level IDE? |
# |
Jul 19th 2021, 16:10 |
tyler.adam.lazenby |
what did you mean the sth? @dereuromark |
# |
Jul 19th 2021, 16:10 |
tyler.adam.lazenby |
I am still not finding the issue |
# |
Jul 19th 2021, 15:50 |
ewbarnard |
General comment - I use the @dereuromark IdeHelper now as part of my workflow and it surely does help PhpStorm to help me. I’ve decided to rely entirely on “bake” code generator for Entity/Table class generation followed by invoking illuminator + annotate. My own Model-related code goes in a Repository/ folder specific to the feature I’m developing. I’m pretty sure this approach only became possible over the past |
# |
Jul 19th 2021, 15:50 |
slackebot2 |
year due to various tweaks to “bake” and the IDE Helper. |
# |
Jul 19th 2021, 15:42 |
dereuromark |
you might not properly implement the base task or sth. Make sure to always use the IdeHelper autocomplete as well, it will also give you hints about invalid task setup. |
# |
Jul 19th 2021, 15:41 |
tyler.adam.lazenby |
But for some reason, this task won't run when I use `bin/cake queue runworker` |
# |
Jul 19th 2021, 15:40 |
tyler.adam.lazenby |
```^C-bash-4.2$ env PATH="/opt/plesk/php/8.0/bin:$PATH" bin/cake queue stats Total unfinished jobs: 1 Running workers (processes): 0 Server name: plesk04.eznettools.net --------------------------------------------------------------- Jobs currently in the queue: - AddContacts : 1 --------------------------------------------------------------- Finished job statistics:``` |
# |
Jul 19th 2021, 15:40 |
tyler.adam.lazenby |
@dereuromark I can't seem to figure out why this task isn't being picked up by the runner |
# |
Jul 19th 2021, 14:16 |
admad |
@isvyas well than my 1st question stands :) |
# |
Jul 19th 2021, 13:00 |
greg138 |
@rudy1976s, what does your fixture look like? And what does "not able to work" mean? |
# |
Jul 19th 2021, 12:45 |
isvyas |
@admad No, it's the components directory for Vue or JS specific code. |
# |
Jul 19th 2021, 12:18 |
admad |
Is `resources/js/components/AppGreet.vue` withing `ROOT/templates` too? |
# |
Jul 19th 2021, 12:17 |
admad |
Overtime I imagine I would be trying to remember whether a chunk of HTML is coming from a Cake template or a .vue file. |
# |
Jul 19th 2021, 12:16 |
admad |
@isvyas what's the benefit of having the layout and `templates/Pages/greet.php` generated through Cake? Having some on your HTML as Cake templates and that for components as pure .vue files doesn't seem very good for management. |
# |
Jul 19th 2021, 11:37 |
rudy1976s |
Hello !!! I am writing a text for a table which has a json column. I have warnings by phpunit related : it seems that fixture is not able to work with json data. is that possible ? is there something to know about it ? |
# |
Jul 19th 2021, 11:31 |
isvyas |
Hi Guys, Checkout my latest blog post on how to integrate Vue.js with CakePHP: https://ishanvyas.hashnode.dev/integrate-vuejs-with-cakephp-framework Feedback appreciated :raised_hands::skin-tone-3: Let me know if I'm missing anything. Also, suggest the topics in which you guys need blog posts so if I have knowledge about it I can create an article on it. |
# |
Jul 19th 2021, 11:24 |
admad |
@slack1780 this->element('nav', ['id' => $identity]) |
# |
Jul 18th 2021, 22:38 |
kevin.pfeifer |
yes, the identity object is not automatically set in the view either you get it via the request object (same way as in controller) inside your template or set the identity variable in the appcontroller so its present everywhere without going through the request everytime |
# |
Jul 18th 2021, 21:22 |
kevin.pfeifer |
there is also this plugin https://github.com/icings/menu which uses the KnpMenu But I never used it so :man-shrugging: |
# |
Jul 18th 2021, 20:47 |
kevin.pfeifer |
no problem, just type it in and someone will help you :) |
# |
Jul 18th 2021, 20:32 |
kevin.pfeifer |
:thinking_face: then you should regenerate the model cache i guess ```bin/cake cache clear_all``` |