Log message #4262171

# At Username Text
# Apr 30th 2021, 07:28 revillosakristianpaol I have another question, how do i update record with records from previous data in sql it look like this "update table set quantity = quantity+10 where Id = 4;
# Apr 30th 2021, 07:27 revillosakristianpaol Thanks for the update
# Apr 30th 2021, 07:21 slackebot $entity = $this->MyTable->get($data['id']); $entity = $this->MyTable->patchEntity( $entity, $data ); if( $this->MyTable->save( $entity ) ) { $outcome['success'][] = $data['id'] . ' (' . $data['name'] . ')'; } else { $outcome['error'][] = $data['id'] . ' (' . $entity->getErrors() . ')'; } }```
# Apr 30th 2021, 07:21 kevin.pfeifer `updateAll()` basically executes the update command directly and returns the number of rows affected But as far as I know there is no validation process being done here so your custom validator rules don’t apply if you update your entries like that. If you want to know per entry/entity what validation errors you get you should do something like this: ``` $outcome = []; foreach($new_data_array, $data) {
# Apr 30th 2021, 06:58 revillosakristianpaol how to know if $table->updateAll executed successfully
# Apr 30th 2021, 06:58 revillosakristianpaol hi
# Apr 30th 2021, 06:46 admad `--skel` is replaced by `--theme` in Cake 4, you'll have to replicae the `project` command yourself.
# Apr 30th 2021, 06:04 paolo.bragagni (I'd like to replicate for new projects, then I'll think to porting..)
# Apr 30th 2021, 06:04 paolo.bragagni In your opinion which is the best way?
# Apr 30th 2021, 06:03 paolo.bragagni I have more that 100 projects built in that way (in few linux servers) and I'd like to 'replicate' it in cakephp 4
# Apr 30th 2021, 06:02 paolo.bragagni was 'son' of /var/www/html/cake2.10.16/
# Apr 30th 2021, 06:01 paolo.bragagni so al my project built with ./cake bake project --skel Templates/myskel
# Apr 30th 2021, 06:01 paolo.bragagni my skel pointed to /var/www/html/cake2.10.16/ for 'core'
# Apr 30th 2021, 06:00 paolo.bragagni and I had built a skel whit all my changing, plugins, ecc..
# Apr 30th 2021, 05:59 paolo.bragagni In my 'old' cakephp 2 linux server I had a 'core' in (example) /var/www/html/cake2.10.16/
# Apr 30th 2021, 05:58 paolo.bragagni trying to find a way to replicate 'cake bake project' .. :S
# Apr 29th 2021, 22:05 greg138 My memory is not what it used to be. Also, my memory is not what it used to be.
# Apr 29th 2021, 22:04 greg138 That is indeed what I meant.
# Apr 29th 2021, 21:56 kevin.pfeifer i guess you mean 81 ;)
# Apr 29th 2021, 21:49 greg138 What does line 181 of `C:\xampp\htdocs\ezBusinessManager\src\Controller\AccountsController.php` look like?
# Apr 29th 2021, 21:48 kevin.pfeifer or check if your UploadedFile object ib your test is actually what you expect it to be
# Apr 29th 2021, 21:46 kevin.pfeifer seems like something goes wrong in your controller function where you pass the submitted data aka file to your AWS Component if you got xdebug running you can try to set a breakpoint in your controller function and see what your state is in there when you execute the test
# Apr 29th 2021, 17:33 tyler.adam.lazenby well that didn't make a difference but at least I caught that
# Apr 29th 2021, 17:33 tyler.adam.lazenby ooof its a png
# Apr 29th 2021, 17:32 tyler.adam.lazenby ```$this->enableCsrfToken(); $this->post('/accounts/add', $data); $this->assertResponseOk();```
# Apr 29th 2021, 17:32 tyler.adam.lazenby and finally the test
# Apr 29th 2021, 17:32 tyler.adam.lazenby ```$data = [ 'user' => $user, 'name' => $name, 'phone_number' => $phone_number, 'Addresses' => $Addresses, 'is_billing_same_as_mailing' => "1", 'logo' => $this->testFile, ];```
# Apr 29th 2021, 17:32 tyler.adam.lazenby and here is the data being loaded into an array
# Apr 29th 2021, 17:32 tyler.adam.lazenby here is my file being created in the test ```$this->testFile = new UploadedFile( $testFilePath, filesize($testFilePath), \UPLOAD_ERR_OK, 'logo.png', 'image/jpeg' );```
# Apr 29th 2021, 17:31 slackebot null given, called in C:\xampp\htdocs\ezBusinessManager\src\Controller\AccountsController.php on line 81 in C:\xampp\htdocs\ezBusinessManager\src\Controller\Component\AWSComponent.php on line 124```
# Apr 29th 2021, 17:31 tyler.adam.lazenby Hey there, I am trying to test with post that includes a file upload. I am on the controller test right now, and I have made the file itself a new Laminas/Uploaded file instance. The issue is that when I try to test it via post, it says that the file index is null. ```Error: [TypeError] App\Controller\Component\AWSComponent::createFile(): Argument #1 ($file) must be of type Psr\Http\Message\UploadedFileInterface,
# Apr 29th 2021, 16:35 rightscoreanalysis seems it doesn't return the most relevant results
# Apr 29th 2021, 16:35 rightscoreanalysis if you search the book for 'Components' a bunch of results come back but not https://book.cakephp.org/4/en/controllers/components.html
# Apr 29th 2021, 12:11 etibor I tried to point out from the current layout path by this: $this->viewBuilder()->setLayoutPath('./Administrator/layout'); but it does not help it still stay in the same
# Apr 29th 2021, 11:34 etibor i added this to the routes.php: $routes->connect('administrator/support', ['prefix'=>false,'controller' => 'Contacts', 'action' => 'support']); $this->request->prefix does not show the address in the url in my case, if i could get the real prefix(which is in the url bar) i could set the right menu layout
# Apr 29th 2021, 11:03 slackebot by get the prefix but it does not works, its show false it does not matter in the route I would not like to repeat the layouts in the non prefixed layout Do you have any hint?
# Apr 29th 2021, 11:03 etibor i stuggle with an issue, i use prefixed controllers, however i have non prefixed controllers for commonly used functions i use layouts for the menus(each prefix has different layouts) the issue is that when i try to use the common functions its display its default layout i tried to add a new route which contain the prefix and points to the common function(non-prefixed) and tried to set the layout in the commonly used function
# Apr 29th 2021, 10:57 etibor thank you @st.steinkuehler you are great
# Apr 29th 2021, 09:04 steinkel `$this->getController()->viewBuilder()`
# Apr 29th 2021, 09:03 steinkel @etibor navigate to the Controller from inside the Component first, then you'll be able to get the viewBuilder()
# Apr 29th 2021, 07:55 etibor i use a component for functions used common by different controllers for example i have a user profile function in the component, where i try to change the layout(the menu) like this: $this->viewBuilder()->setLayout($this->request->prefix); but o got: Call to undefined method App\Controller\Component\CommonFunctionsComponent::viewBuilder() how can i use the viewbuilder in a Component?