Logs for #cakephp

Page 3 of 36,386, showing 100 records out of 3,638,536 total, starting on record 201, ending on 300

# At Username Text
# Nov 9th, 15:18 ndm @kevin.pfeifer That would only work when `Table2` is associated via `belongsTo` or `hasOne`, using the `join` strategy.
# Nov 9th, 14:27 kevin.pfeifer The Connection in the Model between Table 1 and Table 2 is correct, that is not the problem
# Nov 9th, 14:26 kevin.pfeifer Hey Chat, I have a question (current CakePHP 4 Version): I like to perform a concatinated where search on my base table and a connected table. ``` $query = $this->Table1->find( 'all' ) ->contain( ['Table2',] ); $search = $current_request->getQuery( 'search' ); $query->where( function( $exp, $q ) use ( $search ) { /** * @var
# Nov 9th, 14:26 slackebot1 QueryExpression $exp * @var Query $q */ // Concatenated Table1 Name $conc1 = $q->func() ->concat( [ 'Table1.first_name' => 'literal', ' ', 'Table1.last_name' => 'literal' ] ); $conc2 = $q->func()
# Nov 9th, 14:26 slackebot1 ->concat( [ 'Table1.last_name' => 'literal', ' ', 'Table1.first_name' => 'literal' ] ); // Concatenated Table2 Name $conc3 = $q->func() ->concat( [ 'Table2.first_name' => 'literal', ' ',
# Nov 9th, 14:26 slackebot1 'Table2.last_name' => 'literal' ] ); $conc4 = $q->func() ->concat( [ 'Table2.last_name' => 'literal', ' ', 'Table2.first_name' => 'literal' ] ); return $exp->or( [
# Nov 9th, 14:26 slackebot1 'Table1.company LIKE' => "%$search%", 'Table1.first_name LIKE' => "%$search%", 'Table1.last_name LIKE' => "%$search%", 'Table1.city LIKE' => "%$search%", 'Table2.first_name LIKE' => "%$search%", 'Table2.last_name LIKE' => "%$search%" ] )
# Nov 9th, 14:26 slackebot1 ->like( $conc1, "%$search%" ) ->like( $conc2, "%$search%" ) ->like( $conc3, "%$search%" ) ->like( $conc4, "%$search%" ); } ); ``` But when i search something i get the error: ``` Column not found: 1054 Unknown column 'Table2.first_name' in 'where clause' ``` Therefore CakePHP doesnt seem to perform the join between Table1 and Table2. Do i do something wrong?
# Nov 9th, 09:16 alexdd55976 morning
# Nov 9th, 03:12 francisdoydora nevermind, figured it out :slightly_smiling_face:
# Nov 9th, 02:52 francisdoydora good morning everyone :slightly_smiling_face: ```$this->Auth->identify()``` fails when I put it in a Cell. anyway this can be fixed? error returned is ```Error: Method App\View\Cell\SwitchSidebarCell::__toString() must not throw an exception, caught Error: Could not render cell - Call to a member function identify() on null [/var/www/html/juniorhigh/src/View/Cell/SwitchSidebarCell.php, line 39]```
# Nov 8th, 21:09 sdevore > You can use the second parameter of Router::connect() to provide any routing parameters that are composed of the default values of the route: ``` Router::connect( '/government', array('controller' => 'pages', 'action' => 'display', 5) ); ```
# Nov 8th, 21:06 ricksaccous might need the double star i dunno
# Nov 8th, 21:06 ricksaccous ie just write the link using controller/action params but in routes make it route to /contact/*
# Nov 8th, 21:05 ricksaccous why aren't you using routes to handle this for you
# Nov 8th, 20:56 devito if you use the string I would need to build the query param and concat it it would seem.
# Nov 8th, 20:50 sdevore well you can always just use the string you want. Although is is a bit limiting. Let me look at another project here in a little bit and see if I did anything specific in that project because I am pretty sure I have handled in it differently
# Nov 8th, 20:17 devito i am also using query string params other wise I would just specify the url as a string
# Nov 8th, 20:16 devito got a cake2 html helper question. When using the link function and specifying a controller and action, is there a way to have the url go to the named route declaration instead of the controller/action route? like just go to /contact instead of /pages/contact ?
# Nov 8th, 18:39 samuel.assuncao @amanfulgence what youi want to do specifcally
# Nov 8th, 17:49 amanfulgence help me how create and use middelware
# Nov 8th, 17:18 samuel.assuncao Someone got a idea ?
# Nov 8th, 17:18 samuel.assuncao $purchases = TableRegistry::get('Purchases')->find() ->where([ 'data_compra <=' => $date, 'volume_comprado + volume_transferido - volume_devolvido - volume_vendido > 0' ]) //certo ->matching('Plants') ->orderAsc('Plants.razao_social') ->orderAsc('Purchases.created') ->contain([ 'Distributors',
# Nov 8th, 17:18 slackebot1 'Plants' ]); But Instead of getting the actual saved value from my table Purchase, I need get the data from the tables from a certain date. Sales Purchases to get volume_vendido -> created date and filter it to the $date(which is YYYY-MM-DD already) I also need the same for Purchases_Transfers (which is volume_transferido) and Purchase_Devolutions (which is volume_devolvido) So I need a where condition which will filter the
# Nov 8th, 17:18 slackebot1 associations too, I do not see any example on documentation how i can do that with the cake ORM
# Nov 8th, 17:18 samuel.assuncao Hi guys!
# Nov 8th, 12:51 dev.cyrusjayson and more <3
# Nov 8th, 12:50 dev.cyrusjayson more <3 here
# Nov 8th, 12:47 dev.cyrusjayson oh!
# Nov 8th, 12:46 frank @dev.cyrusjayson Yeah, it’s just because it’s looking in the namespace of your controller when you don’t define it at the top
# Nov 8th, 12:43 dev.cyrusjayson that is the response
# Nov 8th, 12:43 frank @dev.cyrusjayson use Cake\ORM\Query; at the top
# Nov 8th, 12:43 dev.cyrusjayson I get this error ``` [TypeError] Argument 1 passed to App\Controller\FruitsController::App\Controller\{closure}() must be an instance of App\Controller\Query, instance of Cake\ORM\Query given, called in ...```
# Nov 8th, 12:40 frank @dev.cyrusjayson This is what I mean, does this give the error also? ``` $fruits = $this->Fruits->find('all') ->contain(['GaveFruits' => function (Query $q) { return $q ->select(['id', 'name']) ->where(['user_id' => 1]); }]); ```
# Nov 8th, 12:37 frank @dev.cyrusjayson Wait, so with the `=>` it gave that as well?
# Nov 8th, 12:35 dev.cyrusjayson ‘Illegal offset type in isset or empty’
# Nov 8th, 12:32 frank @dev.cyrusjayson Okay, yeah that should work. What did the internal server error say, did it provide any context?
# Nov 8th, 12:31 dev.cyrusjayson here
# Nov 8th, 12:30 dev.cyrusjayson gave_fruits, sorry not in the screenshot
# Nov 8th, 12:29 frank @dev.cyrusjayson In which table is the user_id?
# Nov 8th, 12:24 dev.cyrusjayson this is the models
# Nov 8th, 12:22 dev.cyrusjayson following this is not helping https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#passing-conditions-to-contain
# Nov 8th, 12:20 dev.cyrusjayson An Internal Server Error Occurred
# Nov 8th, 12:19 dev.cyrusjayson @frank I got internal error this is only thing is working but I want to filter the GaveFruits by user_id so I can get specific only ```$fruits = $this->Fruits->find('all') ->contain(['GaveFruits']);```
# Nov 8th, 12:16 frank @dev.cyrusjayson Could you try `'GaveFruits' => function ….` instead of `'GaveFruits', function ….` (arrow vs comma)
# Nov 8th, 12:08 dev.cyrusjayson I have this query ``` $fruits = $this->Fruits->find('all') ->contain(['GaveFruits',function (Query $q){ return $q ->select(['id', 'name']) ->where(['user_id' => 1]); }]); ``` and I get this error ```Warning (2): Illegal offset type in isset or empty
# Nov 8th, 12:08 slackebot1 [CORE/src/ORM/EagerLoader.php, line 410]``` but if I remove the ->where([‘user_id’ => 1]) everything is working so I think the problem is in ->where but based on the documentation, I am fopllowing it correctly
# Nov 8th, 12:01 pieceof whoami
# Nov 8th, 11:01 dev.cyrusjayson @frank noted on that. thanks
# Nov 8th, 10:59 frank @dev.cyrusjayson You can remove the foreignKey from the association definition. As you’re following the conventions Cake will know to use user_id for Users.
# Nov 8th, 10:52 dev.cyrusjayson sorry. it all works. thanks mate. that fucking cache save the day
# Nov 8th, 10:45 graziel what do you mean not working? you get error or something?
# Nov 8th, 10:38 dev.cyrusjayson This works! thank you. ``` $this->paginate = [ 'contain' => ['Customers', 'Statuses', 'Users'] ]; $orders = $this->paginate($this->Orders); $this->set(compact('orders')); ``` but my association not working. see below ``` $this->belongsTo('Users', [ 'foreignKey' => 'user_id' ]); ```
# Nov 8th, 10:34 dereuromark Going to release TinyAuth next generation auth plugin if someone wants to give early feedback before I release the major? Ideally the ones already using it and checking BC etc.
# Nov 8th, 10:31 dev.cyrusjayson ok
# Nov 8th, 10:31 graziel bin/cake orm_cache clear
# Nov 8th, 10:31 dev.cyrusjayson how?
# Nov 8th, 10:31 graziel try clearing orm cache
# Nov 8th, 10:31 dev.cyrusjayson do I need to compile something?
# Nov 8th, 10:30 dev.cyrusjayson what is going on. kinda frustrating
# Nov 8th, 10:30 dev.cyrusjayson even here I can’t see the user_id ``` $this->paginate = [ 'contain' => ['Customers', 'Statuses', 'Users'] ]; $orders = $this->paginate($this->Orders); $this->set(compact('orders')); ```
# Nov 8th, 10:29 dev.cyrusjayson it is not a field. it is association in users model
# Nov 8th, 10:28 dev.cyrusjayson ``` public function initialize(array $config) { parent::initialize($config); $this->setTable('orders'); $this->setDisplayField('id'); $this->setPrimaryKey('id'); $this->belongsTo('Customers', [ 'foreignKey' => 'customer_id' ]); $this->belongsTo('Statuses', [ 'foreignKey' => 'status_id' ]); $this->belongsTo('Users', [
# Nov 8th, 10:28 slackebot1 'foreignKey' => 'user_id' ]); $this->hasMany('Suborders', [ 'foreignKey' => 'order_id' ]); } ```
# Nov 8th, 10:28 dev.cyrusjayson ```
# Nov 8th, 10:28 dev.cyrusjayson ``` public function validationDefault(Validator $validator) { $validator ->integer('id') ->allowEmptyString('id', null, 'create'); $validator ->scalar('name') ->maxLength('name', 255) ->allowEmptyString('name'); $validator ->scalar('code') ->maxLength('code', 45) ->allowEmptyString('code'); return
# Nov 8th, 10:28 slackebot1 $validator; } ```
# Nov 8th, 10:27 challgren ‘user’ isn’t though
# Nov 8th, 10:27 dev.cyrusjayson yes ``` protected $_accessible = [ 'user_id' => true, 'name' => true, 'customer_id' => true, 'status_id' => true, 'remarks' => true, 'is_paid' => true, 'date_created' => true, 'customer' => true, 'status' => true, 'suborders' => true ]; ```
# Nov 8th, 10:27 challgren is the field accessible?
# Nov 8th, 10:26 dev.cyrusjayson it just seems cake don’t know user_id added
# Nov 8th, 10:26 dev.cyrusjayson there is no error though
# Nov 8th, 10:26 dev.cyrusjayson I cant see it also. and I have association that gives user as null. but the user_id is not also there
# Nov 8th, 10:25 challgren Check `$entity>errors()`
# Nov 8th, 10:25 dev.cyrusjayson I added new field name user_id in table [11:14 AM] it is not saving [11:14 AM] even I was passing the data
# Nov 8th, 10:12 jotpe Hey :wave:
# Nov 8th, 09:31 dereuromark If they can be null why are they relevant for the query? ;) i think this is a design issue in most cases.
# Nov 8th, 09:25 spriz I would assume the performance of such query is not great :) :)
# Nov 8th, 09:25 roel Oh thanks :)
# Nov 8th, 09:24 roel @spriz the date columns can be `null`
# Nov 8th, 09:19 spriz @roel but one way could be this: https://gist.github.com/Spriz/3862a1bee5a8d67ef7b85434e61be9ad
# Nov 8th, 09:14 noel @martonmiklosqdev I suggest you use xdebug in that case. Not sure why the line numbers aren't showing up correctly for you. This happens to me in JavaScript quite often and it's very annoying. I've never seen it in PHP.
# Nov 8th, 09:13 spriz @roel does the date column really have `0` and not `null` in the DB?
# Nov 8th, 08:59 roel `SELECT * FROM `<table>` WHERE `<fk_id>` IN (1,2)` ` ORDER BY GREATEST(COALESCE(`<date_column_1>`, 0), COALESCE(`<date_column_2>`, 0)) DESC` ` LIMIT 10`
# Nov 8th, 08:59 roel The query is as follows:
# Nov 8th, 08:59 roel Hello everyone, I have a SQL query that I would like to convert to a cakephp (3.6) query, but I have no clue how to do it and if it is even possible.
# Nov 8th, 08:19 javier.villanueva I think that your models are different than the models im thinking
# Nov 8th, 08:18 javier.villanueva morning all
# Nov 8th, 06:36 conehead Morning!
# Nov 8th, 06:17 alexdd55976 Morning
# Nov 8th, 01:50 ndm Check `$context['newRecord']`
# Nov 8th, 01:47 francisdoydora thanks in advance for your help :slightly_smiling_face:
# Nov 8th, 01:47 francisdoydora if update, allowEmptyFile. Else if create, follow the validator rule I posted.
# Nov 8th, 01:37 francisdoydora if anyone could help me figure out how to return 'update' as default. But needs to return true or false on create. Right now allowEmptyFile returns false if academic_level_id is not equal to 1. But I didn't take into account if I want to edit. In edit it should always allow empty files. ```$validator ->allowEmptyFile('gmrc', 'Please upload a GMRC', function ($context) { if
# Nov 8th, 01:37 slackebot1 (isset($context['data']['academic_level_id'])) { return $context['data']['academic_level_id'] === '1'; } return true; })```
# Nov 7th, 23:24 mrfeedback is there a way to disable a virtual field when a query is returning entities? In my case I dont need that specific field as it generates s3links which I wouldn´t use in that case. I tried to not select the field. but for some reason it still triggers
# Nov 7th, 22:41 slackebot1 <martonmiklosqdev>
# Nov 7th, 22:40 martonmiklosqdev I can see the problematic line in the variables pane:
# Nov 7th, 22:40 martonmiklosqdev the view errors a bit better
# Nov 7th, 22:40 martonmiklosqdev where the problem is in the view