# |
Apr 30th 2021, 16:21 |
martin |
@kevin.pfeifer but that uses the cakedc auth, not the authorization middleware? |
# |
Apr 30th 2021, 16:15 |
kevin.pfeifer |
@sebias |
# |
Apr 30th 2021, 16:15 |
kevin.pfeifer |
@martin look at the AuthLinkHelper from CakeDC https://github.com/CakeDC/users/blob/master/src/View/Helper/AuthLinkHelper.php |
# |
Apr 30th 2021, 16:13 |
sebastiansperandio093 |
Could someone to suggest the best option for wysiwyg editor in cakephp 4? |
# |
Apr 30th 2021, 16:13 |
martin |
was hoping i was able to just create a virtual field inside entity where I can return $user->can(‘edit’, $this); :P |
# |
Apr 30th 2021, 16:08 |
martin |
I’ve policies to check if the user is allowed to edit the entity. but since it is a api response, and user will see all entities the frontent needs to know which one can be edited |
# |
Apr 30th 2021, 16:08 |
kevin.pfeifer |
which therefore needs access to the table object |
# |
Apr 30th 2021, 16:07 |
kevin.pfeifer |
because `canEdit` authorizations are usually handled via Policies |
# |
Apr 30th 2021, 16:07 |
martin |
yes |
# |
Apr 30th 2021, 16:07 |
kevin.pfeifer |
you mean inside the entity of which should be checked against the current logged in user? |
# |
Apr 30th 2021, 15:56 |
martin |
Can I access the authorization inside a entity? I need to have in api response if user can edit a entity. |
# |
Apr 30th 2021, 13:42 |
louis |
Does it indent well your template file ? Php is well formatted but the HTML is not |
# |
Apr 30th 2021, 13:23 |
louis |
Thanks @admad ! |
# |
Apr 30th 2021, 13:12 |
admad |
install https://github.com/cakephp/cakephp-codesniffer/ so can use can use the coding standard "CakePHP" for phpcs |
# |
Apr 30th 2021, 13:11 |
admad |
@louis don't use intelephense's code formatter. Install this plugin for phpcs https://github.com/wongjn/vscode-php-sniffer and use that for formatting. |
# |
Apr 30th 2021, 12:49 |
sebastiansperandio093 |
I just use it when vscode "make yours" |
# |
Apr 30th 2021, 12:49 |
sebastiansperandio093 |
but I dont use too |
# |
Apr 30th 2021, 12:48 |
sebastiansperandio093 |
mmm I have a plugin called beautify |
# |
Apr 30th 2021, 12:33 |
louis |
Hello there, First time i’m working on a CakePHP 4 app, layout extension is now .php. I struggle with indent, VScode with intelephense broke all indent :,( |
# |
Apr 30th 2021, 11:13 |
joacir.santos |
@revillosakristianpaol I think you should use Expression like this: ```$expression = new QueryExpression('quantity = quantity + 10'); $updated = $this->updateAll([$expression], ['id' => 4]);``` |
# |
Apr 30th 2021, 08:10 |
kevin.pfeifer |
even though it should in my opinion |
# |
Apr 30th 2021, 08:10 |
kevin.pfeifer |
i am trying that right now too but somehow this doesn’t work ```$this->Projects->updateAll(['Projects.netto' => 'Projects.netto + 1'], ['Projects.id' => 3]);``` |
# |
Apr 30th 2021, 07:50 |
revillosakristianpaol |
im using updateAll |
# |
Apr 30th 2021, 07:47 |
kevin.pfeifer |
are you using the patchEntity method or the updateAll method? |
# |
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. |