# |
Aug 22nd 2019, 12:55 |
challgren |
But in reality its a failure on our part since we arent using the correct skeleton after a version update |
# |
Aug 22nd 2019, 12:54 |
challgren |
Yeah I looked through the app and Im pretty sure most of us here built our apps before Dec 8th so its a hodge podge of everything |
# |
Aug 22nd 2019, 12:53 |
admad |
@challgren ah that might be it, regarding csrf middleware. Earlier the whitelisting feature was not available that it why it was moved to router in skeleton app |
# |
Aug 22nd 2019, 12:53 |
challgren |
Bugger |
# |
Aug 22nd 2019, 12:52 |
mehov |
@challgren thanks, but `Warning (4096): Object of class Cake\Database\Expression\FunctionExpression could not be converted to string` |
# |
Aug 22nd 2019, 12:49 |
challgren |
Try. FYI I am no ORM expert |
# |
Aug 22nd 2019, 12:46 |
mehov |
I'm afraid I need it once and for that query only, so I think I shouldn't be modifying the Entity. Right now I have: ``` $query->select([ $query->newExpr([ '@salesTotal := ', $query->func()->sum('Table.total') ]), ]); ``` But that results in `@salesTotal := AND SUM(Table.total` |
# |
Aug 22nd 2019, 12:43 |
challgren |
@mehov https://book.cakephp.org/3.0/en/orm/entities.html#creating-virtual-fields |
# |
Aug 22nd 2019, 12:42 |
mehov |
Guys, is there any way to use MySQL user-defined variables with Cake\ORM\Query? Here's an example: https://dba.stackexchange.com/a/224756 ``` SELECT @earnings := (`house_rent`+`conveyance`+`medical`+`dearness`+`others_allowances`) AS earnings , @deductions := (`income_tax`+`pro_tax`+`emp_state_insu`+`absence_fine`+`others_deductions`) AS deductions, @earnings - @deductions AS net_salary FROM salary ``` |
# |
Aug 22nd 2019, 12:40 |
scuadra |
is there something like 'last' => true for validation as in Cake 2 :face_with_rolling_eyes: |
# |
Aug 22nd 2019, 12:36 |
rchavik |
dammit, it was misconfigure nginx conf |
# |
Aug 22nd 2019, 12:34 |
scuadra |
thank you very much for the help |
# |
Aug 22nd 2019, 12:34 |
challgren |
I think a lot of the confusion regarding the CSRF middleware is that old cakephp/app installs have the middleware registering in the Application::middleware() but newer have it in the routes.php |
# |
Aug 22nd 2019, 12:34 |
scuadra |
it's ok now |
# |
Aug 22nd 2019, 12:33 |
neon1024 |
Perhaps the documentation can be improved :slightly_smiling_face: |
# |
Aug 22nd 2019, 12:32 |
alexdd55976 |
i tripped over that too, when i first used custom validation |
# |
Aug 22nd 2019, 12:30 |
scuadra |
very very ashamed... :| |
# |
Aug 22nd 2019, 12:28 |
scuadra |
so it's whatever I want :slightly_smiling_face: |
# |
Aug 22nd 2019, 12:28 |
scuadra |
I thought that when I add custom rules the second parameter should always be 'custom'... |
# |
Aug 22nd 2019, 12:27 |
scuadra |
ahh... |
# |
Aug 22nd 2019, 12:27 |
neon1024 |
`->add('arrival', 'beforeDeparture', [` |
# |
Aug 22nd 2019, 12:27 |
neon1024 |
Personally I just name the rule |
# |
Aug 22nd 2019, 12:26 |
scuadra |
so they should be something like custom_first and custom_second? |
# |
Aug 22nd 2019, 12:26 |
neon1024 |
That might be why? |
# |
Aug 22nd 2019, 12:26 |
neon1024 |
@scuadra You’ve named them the same ‘custom’ |
# |
Aug 22nd 2019, 12:25 |
scuadra |
but I seems that the first custom rule does not work at all |
# |
Aug 22nd 2019, 12:25 |
scuadra |
I tried with: return $validator ->requirePresence(['arrival', 'departure']) ->date('arrival', ['ymd'], __('Please select a valid date')) ->add('arrival', 'custom', [ 'rule' => function ($value, $context) { ... }, 'message' => __('Arrival date must preceed departure date'), ]) ->add('arrival', 'custom', [ 'rule' => function ($value, $context) { ... }, 'message' => __('Incorrect arrival date'), ]); |
# |
Aug 22nd 2019, 12:21 |
scuadra |
Hello. In Cake 3 how can I add 2 (or more) custom validation rules for a given field? |
# |
Aug 22nd 2019, 12:13 |
rchavik |
what does the query parsing in 3.8? |
# |
Aug 22nd 2019, 11:54 |
alexdd55976 |
me neither... i used skipauthorization to get access :) |
# |
Aug 22nd 2019, 11:54 |
rchavik |
If i configure routes as follows, ```php Router::prefix('api', function($routes) { $routes->setExtensions('json'); $routes->resources('Nodes'); }); ``` will it strip url queries? |
# |
Aug 22nd 2019, 11:54 |
neon1024 |
@alexdd55976 I don’t even know how to get it working, let alone try and write docs for it ,:) |
# |
Aug 22nd 2019, 11:53 |
alexdd55976 |
@neon1024 while you are doing that you could improve the authorization middleware documention as well :) |
# |
Aug 22nd 2019, 11:53 |
neon1024 |
Perhaps it would make a great Cakefest talk! |
# |
Aug 22nd 2019, 11:53 |
neon1024 |
I looked in Application.php for Middleware, and CSRF is in routes.php! |
# |
Aug 22nd 2019, 11:53 |
neon1024 |
If you were a beginner you’d have no idea what was going on |
# |
Aug 22nd 2019, 11:52 |
neon1024 |
You just get an exception |
# |
Aug 22nd 2019, 11:52 |
neon1024 |
The point being that CSRF and Security feel a bit muddled, and they’re a hard stop for development |
# |
Aug 22nd 2019, 11:52 |
slackebot2 |
<alexdd55976> |
# |
Aug 22nd 2019, 11:52 |
neon1024 |
For a beginner, well… |
# |
Aug 22nd 2019, 11:52 |
neon1024 |
I’m hardly the worlds greatest idiot and I couldn’t work it out |